diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6139a46 Binary files /dev/null and b/.DS_Store differ diff --git a/action_borrowing.php b/action_borrowing.php new file mode 100755 index 0000000..17ef403 --- /dev/null +++ b/action_borrowing.php @@ -0,0 +1,1201 @@ +dd_id != $_GET["dd_id"]) + sendAjaxXML(501, getConstVar('ERR_ALREADY_OPENED_REQUEST'), null, null); + else { + $borrow = new Borrowing($_GET["dd_id"]); + $borrow->componi_pannello(); + $_SESSION['str_borrow'] = serialize($borrow); + unset($_SESSION['cataloghi_results']); + } + } else { + $borrow = new Borrowing($_GET["dd_id"]); + if (!is_null($borrow->ri_doi)) + echo ' + + + ' . getConstVar("ARTICOLO_DOWNLOAD") . ' + + '; + else if (!is_null($borrow->ri_pmid)) + echo ' + + + ' . getConstVar("ARTICOLO_DOWNLOAD") . ' + + '; + $borrow->componi_pannello(); + $_SESSION['str_borrow'] = serialize($borrow); + unset($_SESSION['cataloghi_results']); + } + break; + + case "check_req_session" : + if (isset($_SESSION) && isset($_SESSION['str_borrow'])) + sendAjaxXML(501, getConstVar('ERR_ALREADY_OPENED_REQUEST'), null, null); + else + sendAjaxXML(201, null, null, null); + break; + + case "new_req": + $borrow = new Borrowing(null, $_GET["req_type"], $_SESSION['biblio']->bi_id); + $borrow->componi_pannello(); + $_SESSION['str_borrow'] = serialize($borrow); + unset($_SESSION['cataloghi_results']); + + break; + + case "new_req_openurl": + $borrow = new Borrowing(null, $_GET["req_type"], $_GET["idrich"], $_GET["idforni"]); + $borrow->nuovo_openurl($_GET["req_type"]); + $_SESSION['str_borrow'] = serialize($borrow); + break; + + + case "choose_type": + echo ""; + echo "
"; + echo "
"; + echo "
"; + echo getConstVar("DOCUMENT_TYPE_SEL"); + echo "

"; + echo "> " . getConstVar("ARTICOLO") . "

\n"; + echo getConstVar("SEARCH_TO_HEAL_PORTAL") . "\n"; + + echo "
\n"; + echo "
"; + break; + + case "elimina": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $ok = $borrow->elimina(); + $borrow->__destruct(); + clear_borrowing_session(); + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) + sendAjaxXML(201, getConstVar("MSG_DELETE_REFERENCES"), null, null); + else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + break; + + case "ric_annulla": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $borrow->dd_stato_ddill = getConstVar("DDILL_RICHIESTO_ANNULLA"); + $_SESSION['str_borrow'] = serialize($borrow); + $ok = $borrow->aggiornaDB(); + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $ok_2 = $borrow->set_data_annullamento(); + sendAjaxXML(201, getConstVar("MSG_NULL_REQ"), null, null); + } else { + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } + } else { + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + } + break; + + case "ute_norisp": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $borrow->dd_stato_borr = getConstVar("BORR_UTE_NORISP"); + $borrow->dd_stato_accetta = getConstVar("STATO_ACC_NONRISPONDE"); + $_SESSION['str_borrow'] = serialize($borrow); + $ok = $borrow->aggiornaDB(); + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $borrow = new Borrowing($borrow->dd_id); + $form = new FieldsForm("form_richiesta"); + $borrow->reset_controllo(); + $borrow->box_riferimento_visualizza($form); + $borrow->box_bottoni($form); + $_SESSION['str_borrow'] = serialize($borrow); + sendAjaxXML(201, "", null, $form->restituisci()); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + break; + + + case "save_req": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $controllo["bi_idforni"]["obbligo"] = 0; + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $borrow->aggiornaObject($_POST); + $_SESSION['str_borrow'] = serialize($borrow); + $flag = false; + if ($borrow->isNewRequest()) { + $ok = $borrow->inserisciDB(); + $flag = true; + } else + $ok = $borrow->aggiornaDB(); + + if ($ok) { + if ($flag) + sendAjaxXML(201, getConstVar("MSG_REFERENCE_INSERT"), null, null); + else if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) + sendAjaxXML(201, getConstVar("MSG_REFERENCE_INSERT"), null, null); + else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + unset($_SESSION['cataloghi_results']); + } + break; + + + case "avanti": + case "reinoltra": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $errore_richie = ControlloCampi::check_richiesta($_POST, $borrow->ri_tipomateriale); + if (!$errore_richie) { + $borrow->aggiornaObject($_POST); + $form = new FieldsForm("form_richiesta"); + $borrow->reset_controllo(); + + $borrow->box_riferimento_visualizza($form); + $borrow->box_biblioteche($form); + $borrow->box_bottoni($form, 2); + $_SESSION['str_borrow'] = serialize($borrow); + + $res = $form->restituisci(); + + sendAjaxXML(201, null, $errore, $res); + } else + sendAjaxXML(504, getConstVar("ERR_REFERENCE_REQUEST_INCOMPLETE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "cambia_lista": + $_SESSION['tipo'] = $_REQUEST["tipo"]; + $_SESSION['biborder'] = "bi_rank"; + $_SESSION['bibpasso'] = "100"; + $_SESSION['bibqualif'] = "asc"; + $_SESSION['bibstart'] = "0"; + + $borrow = unserialize($_SESSION['str_borrow']); + $borrow->reset_controllo(); + echo $borrow->pannello_biblioteche($_SESSION['biblio']->bi_id, $_SESSION['tipo'], $_SESSION['biborder'], $_SESSION['bibqualif'], $_SESSION['bibstart'], $_SESSION['bibpasso']); + break; + + case "aggiorna": + $borrow = unserialize($_SESSION['str_borrow']); + echo $borrow->elenco($_SESSION['biblio']->bi_id, $_SESSION['tipo'], $_SESSION['biborder'], $_SESSION['bibqualif'], $_SESSION['bibstart'], $_SESSION['bibpasso']); + $_SESSION['str_borrow'] = serialize($borrow); + break; + + case "rich_settimanali": + $borrow = unserialize($_SESSION['str_borrow']); + echo $borrow->richieste_settimanali($_GET["idforni"], $_SESSION['tipo']); + $_SESSION['str_borrow'] = serialize($borrow); + break; + + case "bottoni_biblio_nilde": + $borrow = unserialize($_SESSION['str_borrow']); + $form = new FieldsForm(); + if ($borrow->dd_stato_borr == getConstVar("BORR_NUOVO") || $borrow->dd_stato_borr == getConstVar("BORR_REINOLTRO")) + $borrow->box_bottoni_richiediNILDE($form, "nuovo_richiedi_nilde"); + else + $borrow->box_bottoni_richiediNILDE($form, "ripeti_richiedi_nilde"); + $borrow->box_bottoni_indietro($form); + + $form->stampa(); + break; + + case "bottoni_biblio_fuorinilde": + $borrow = unserialize($_SESSION['str_borrow']); + $form = new FieldsForm(); + if ($borrow->dd_stato_borr == getConstVar("BORR_NUOVO") || $borrow->dd_stato_borr == getConstVar("BORR_REINOLTRO")) + $borrow->box_bottoni_richiediFN($form, "nuovo_"); + else { + $borrow->box_bottoni_richiediFN($form, "ripeti_"); + } + $borrow->box_bottoni_indietro($form); + $form->stampa(); + $_SESSION['str_borrow'] = serialize($borrow); + break; + + case "indietro": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $form = new FieldsForm("form_richiesta"); + $borrow->reset_controllo(); + $borrow->box_riferimento_edit($form); + $borrow->box_bottoni($form, 1); + $form->close(); + $form->stampa(); + + $_SESSION['str_borrow'] = serialize($borrow); + unset($_SESSION['cataloghi_results']); + } + break; + + case "nuovo_richiedi_nilde": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + if (isset($_POST["bi_idforni"])) + $borrow->bi_idforni = $_POST["bi_idforni"]; + if (isset($_POST["dd_noterichforni"])) + $borrow->dd_noterichforni = $_POST["dd_noterichforni"]; + if (isset($_POST["ca_nome"])) + $borrow->ca_nome = $_POST["ca_nome"]; + if (isset($_POST["dd_nprotrichie"])) + $borrow->dd_nprotrichie = $_POST["dd_nprotrichie"]; + if (isset($_POST["dd_collocazione"])) + $borrow->dd_collocazione = $_POST["dd_collocazione"]; + if (isset($_POST["dd_ninventarioforni"])) + $borrow->dd_ninventarioforni = $_POST["dd_ninventarioforni"]; + if (isset($_POST["dd_note_interne"])) + $borrow->dd_note_interne = $_POST["dd_note_interne"]; + + $borrow->dd_stato_borr = getConstVar("BORR_INOLTRATO"); + $borrow->dd_stato_ddill = getConstVar("DDILL_INOLT_NILDE"); + $data = date("Y-m-d H:i:s"); + $borrow->dd_datarichie = $data; + $borrow->aggiornaObject($_POST); + if ($borrow->isNewRequest()) { + $ddid = $borrow->inserisciDB(); + if ($ddid) + $ok = true; + else + $ok = false; + } else { + $ok = $borrow->aggiornaDB(); + $ddid = $borrow->dd_id; + } + if ($ddid && $ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $borrow->aggiorna_contatore_sett(); + aggiornaReport('nuova_richie_bw', $borrow); + + $resforni = $_SESSION['db']->execute("SELECT bi_nilde,bi_costo_dd,bi_email_dd,bi_scompenso FROM biblio WHERE bi_id=" . $borrow->bi_idforni); + $costo = 0; + $emailforni = ""; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_forni = $_SESSION['db']->fetch($resforni); + + if ($dati_forni['bi_nilde'] == 0) + $costo = $borrow->dd_costofuorinilde; + else + $costo = $dati_forni['bi_costo_dd']; + + $cat_data = isBiblioInCatalog($_SESSION['biblio']->bi_id, 1); + if ($cat_data != null) { + $acnpcod = $cat_data["acnp_cod"]; + } else + $acnpcod = null; + + if ($dati_forni['bi_costo_dd'] == "0.00") { + $array_dati = array('BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow->dd_datarichie, 'NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'COD' => $acnpcod, 'NOTE' => $borrow->dd_noterichforni, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore, 'SCOMPENSO' => $dati_forni['bi_scompenso']); + + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + sendAjaxXML(201, getConstVar("MSG_REQUEST_FW"), null, null); + } else { + $array_dati = array('BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'bi_costo_dd' => $costo, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow->dd_datarichie, 'NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'COD' => $acnpcod, 'NOTE' => $borrow->dd_noterichforni, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore, 'SCOMPENSO' => $dati_forni['bi_scompenso']); + + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + sendAjaxXML(201, getConstVar("MSG_REQUEST_FW"), null, null); + } + } else + sendAjaxXML(502, getConstVar("ERR_LIBRARY_NOT_EXIST"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + elseif (!isset($_POST["bi_idforni"])) + sendAjaxXML(501, getConstVar("ERR_MISSING_LIBRARY"), $errore, null); + else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "nuovo_richiedi_fuorinilde": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + if ($borrow->bi_idforni == "" && isset($_POST["bi_idforni"])) + $borrow->bi_idforni = $_POST["bi_idforni"]; + if (isset($_POST["dd_costofuorinilde"])) { + $borrow->dd_costofuorinilde = $_POST["dd_costofuorinilde"]; + } + if (isset($_POST["dd_nprotrichie"])) + $borrow->dd_nprotrichie = $_POST["dd_nprotrichie"]; + if (isset($_POST["dd_nproteva"])) + $borrow->dd_nproteva = $_POST["dd_nproteva"]; + if (isset($_POST["dd_note_interne"])) + $borrow->dd_note_interne = $_POST["dd_note_interne"]; + + $borrow->dd_stato_borr = getConstVar("BORR_INOLTRATO"); + $borrow->dd_stato_ddill = getConstVar("DDILL_INOLT_FN"); + $data = date("Y-m-d H:i:s"); + $borrow->dd_datarichie = $data; + $borrow->aggiornaObject($_POST); + + if ($borrow->isNewRequest()) { + $ddid = $borrow->inserisciDB(); + if ($ddid) + $ok = true; + else + $ok = false; + } else { + $ok = $borrow->aggiornaDB(); + $ddid = $borrow->dd_id; + } + + if ($ddid && $ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $borrow->aggiorna_contatore_sett(); + aggiornaReport('nuova_richie_bw_fn', $borrow); + + $resforni = $_SESSION['db']->execute("SELECT bi_nilde,bi_costo_dd,bi_email_dd,bi_scompenso FROM biblio WHERE bi_id=" . $borrow->bi_idforni); + $costo = 0; + $emailforni = ""; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_forni = $_SESSION['db']->fetch($resforni); + if ($dati_forni['bi_nilde'] == 0) + $costo = $borrow->dd_costofuorinilde; + else + $costo = $dati_forni['bi_costo_dd']; + + + $cat_data = isBiblioInCatalog($_SESSION['biblio']->bi_id, 1); + if ($cat_data != null) { + $acnpcod = $cat_data["acnp_cod"]; + } else + $acnpcod = null; + + if ($costo == "0.00") { + $array_dati = array('BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow->dd_datarichie, 'NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'COD' => $acnpcod, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore); + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + sendAjaxXML(201, getConstVar("MSG_REFERENCE_INSERT"), null, null); + } else { + $array_dati = array('BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'bi_costo_dd' => $costo, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow->dd_datarichie, 'NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'COD' => $acnpcod, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore, 'SCOMPENSO' => $dati_forni['bi_scompenso']); + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + sendAjaxXML(201, getConstVar("MSG_REQUEST_FW"), null, null); + } + } else + sendAjaxXML(502, getConstVar("ERR_LIBRARY_NOT_EXIST"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + elseif (!isset($_POST["bi_idforni"])) + sendAjaxXML(501, getConstVar("ERR_MISSING_LIBRARY"), $errore, null); + else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "nuovo_informa_ute_fn": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + if (isset($_POST["bi_idforni"])) + $borrow->bi_idforni = $_POST["bi_idforni"]; + if (isset($_POST["dd_costofuorinilde"])) { + $borrow->dd_costofuorinilde = $_POST["dd_costofuorinilde"]; + } + if (isset($_POST["dd_nprotrichie"])) + $borrow->dd_nprotrichie = $_POST["dd_nprotrichie"]; + if (isset($_POST["dd_nproteva"])) + $borrow->dd_nproteva = $_POST["dd_nproteva"]; + if (isset($_POST["dd_note_interne"])) + $borrow->dd_note_interne = $_POST["dd_note_interne"]; + + $borrow->dd_stato_borr = getConstVar("BORR_ATTESA_ACCETTA_UTE_FN"); + $borrow->dd_stato_accetta = getConstVar("STATO_ACC_NORISP"); + $borrow->rm_stato = getConstVar("Rif_BiblioChiedeConferma"); + $borrow->aggiornaObject($_POST); + + $ok = $borrow->aggiornaDB(); + $resid = $_SESSION['db']->execute("SELECT bi_id AS idbiblio FROM appartiene WHERE ut_id=" . $borrow->ut_id); + $idbiblio = ""; + if ($resid && $_SESSION['db']->numrows($resid) == 1) { + $dati_id = $_SESSION['db']->fetch($resid); + $idbiblio = $dati_id['idbiblio']; + $resbibliofn = $_SESSION['db']->execute("SELECT bi_nome FROM biblio WHERE bi_id=" . $borrow->bi_idforni); + $fn = ""; + if ($resbibliofn && $_SESSION['db']->numrows($resbibliofn) == 1) { + $dati_fn = $_SESSION['db']->fetch($resbibliofn); + $fn = $dati_fn['bi_nome']; + $resute = $_SESSION['db']->execute("SELECT ut_nome,ut_cognome,ut_email FROM utente WHERE ut_id=" . $borrow->ut_id); + $email = ''; + $nome = ''; + $cognome = ''; + if ($resute && $_SESSION['db']->numrows($resute) == 1) { + $dati_ute = $_SESSION['db']->fetch($resute); + $email = $dati_ute['ut_email']; + $nome = $dati_ute['ut_nome']; + $cognome = $dati_ute['ut_cognome']; + $array_dati = array('ID_RIF' => $borrow->ri_id, 'BIB_APP' => $_SESSION['biblio']->bi_nome, 'NOME_UT' => $nome, 'COGNOME_UT' => $cognome, 'COSTO' => $borrow->dd_costofuorinilde, 'ORDINE_ID' => $borrow->rm_countbib, 'FORNI' => $fn, 'TITOLO' => $borrow->ri_titolopub); + $testMsg = new Message($array_dati, getConstVar("MAIL9_INFORMACOSTOFN")); + $testMail = new Mail($email, $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTINFORMACOSTO") . $borrow->rm_countbib, $testMsg); + $testMail->send(); + } + } + } + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) + sendAjaxXML(201, getConstVar("MSG_REFERENCE_INSERT"), null, null); + else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + elseif (!isset($_POST["bi_idforni"])) + sendAjaxXML(501, getConstVar("ERR_MISSING_LIBRARY"), $errore, null); + else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "ripeti_richiedi_nilde": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow_old = unserialize($_SESSION['str_borrow']); + $controllo = $borrow_old->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + switch ($borrow_old->dd_stato_borr) { + case getConstVar("BORR_NO_RICEVUTO"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_NO_RIC"); + break; + + case getConstVar("BORR_UTE_RIFIUTA_FN"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_RIFPAG"); + break; + + case getConstVar("BORR_CESTINATO"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_CESTINATO"); + break; + } + + $ok = $borrow_old->aggiornaDB(); + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $ddid = $borrow_old->dd_id; + $borrow_new = new Borrowing(null, $borrow_old->ri_tipomateriale, $borrow_old->bi_idrichie); + $borrow_new->ri_id = $borrow_old->ri_id; + $borrow_new->ut_id = $borrow_old->ut_id; + $borrow_new->rm_countbib = $borrow_old->rm_countbib; + $borrow_new->rm_datarichie = $borrow_old->rm_datarichie; + $borrow_new->dd_polcosti = $borrow_old->dd_polcosti; + $borrow_new->ri_titolopub = $borrow_old->ri_titolopub; + $borrow_new->ri_titolopart = $borrow_old->ri_titolopart; + $borrow_new->ri_au1 = $borrow_old->ri_au1; + $borrow_new->ri_au2 = $borrow_old->ri_au2; + $borrow_new->ri_anno = $borrow_old->ri_anno; + $borrow_new->ri_vol = $borrow_old->ri_vol; + $borrow_new->ri_fasc = $borrow_old->ri_fasc; + $borrow_new->ri_pgini = $borrow_old->ri_pgini; + $borrow_new->ri_pgfine = $borrow_old->ri_pgfine; + if (isset($_POST["bi_idforni"])) + $borrow_new->bi_idforni = $_POST["bi_idforni"]; + if (isset($_POST["dd_noterichforni"])) + $borrow_new->dd_noterichforni = $_POST["dd_noterichforni"]; + if (isset($_POST["dd_nprotrichie"])) + $borrow_new->dd_nprotrichie = $_POST["dd_nprotrichie"]; + if (isset($_POST["dd_collocazione"])) + $borrow_new->dd_collocazione = $_POST["dd_collocazione"]; + if (isset($_POST["dd_ninventarioforni"])) + $borrow_new->dd_ninventarioforni = $_POST["dd_ninventarioforni"]; + if (isset($_POST["dd_note_interne"])) + $borrow_new->dd_note_interne = $_POST["dd_note_interne"]; + + $borrow_new->dd_stato_borr = getConstVar("BORR_INOLTRATO"); + $borrow_new->dd_stato_ddill = getConstVar("DDILL_INOLT_NILDE"); + $borrow_new->dd_datarichie = date("Y-m-d H:i:s"); + $borrow_new->aggiornaObject($_POST); + $ddid = $borrow_new->inserisciDB(); + $borrow_new->aggiorna_contatore_sett(); + aggiornaReport('ripeti_richie_bw', $borrow_new); + sendAjaxXML(201, getConstVar("MSG_REQUEST_FW"), null, null); + + $resforni = $_SESSION['db']->execute("SELECT bi_nilde,bi_costo_dd,bi_email_dd,bi_scompenso FROM biblio WHERE bi_id=" . $borrow_new->bi_idforni); + $costo = 0; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_forni = $_SESSION['db']->fetch($resforni); + if ($dati_forni['bi_nilde'] == 0) + $costo = $borrow_new->dd_costofuorinilde; + else + $costo = $dati_forni['bi_costo_dd']; + + $cat_data = isBiblioInCatalog($_SESSION['biblio']->bi_id, 1); + if ($cat_data != null) { + $acnpcod = $cat_data["acnp_cod"]; + } else + $acnpcod = null; + + if ($dati_forni['bi_costo_dd'] == "0.00") { + + $array_dati = array('LASTDD_ID' => $ddid, 'BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow_new->dd_datarichie, 'NOMERIVISTA' => $borrow_new->ri_titolopub, 'DOI' => $borrow_new->ri_doi, 'TITOLOARTICOLO' => $borrow_new->ri_titolopart, 'AUTORE' => $borrow_new->ri_au1, 'AUTORI' => $borrow_new->ri_au2, 'ANNO' => $borrow_new->ri_anno, 'VOLUME' => $borrow_new->ri_vol, 'FASCICOLO' => $borrow_new->ri_fasc, 'PAGINI' => $borrow_new->ri_pgini, 'PAGFINE' => $borrow_new->ri_pgfine, 'COD' => $acnpcod, 'NOTE' => $borrow_new->dd_noterichforni, 'ISSN' => $borrow_new->ri_issn, 'ISBN' => $borrow_new->ri_isbn, 'EDITORE' => $borrow_new->ri_editore); + + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC")); + if ($borrow_new->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + } else { + $array_dati = array('LASTDD_ID' => $ddid, 'BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'bi_costo_dd' => $costo, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow_new->dd_datarichie, 'NOMERIVISTA' => $borrow_new->ri_titolopub, 'DOI' => $borrow_new->ri_doi, 'TITOLOARTICOLO' => $borrow_new->ri_titolopart, 'AUTORE' => $borrow_new->ri_au1, 'AUTORI' => $borrow_new->ri_au2, 'ANNO' => $borrow_new->ri_anno, 'VOLUME' => $borrow_new->ri_vol, 'FASCICOLO' => $borrow_new->ri_fasc, 'PAGINI' => $borrow_new->ri_pgini, 'PAGFINE' => $borrow_new->ri_pgfine, 'COD' => $acnpcod, 'NOTE' => $borrow_new->dd_noterichforni, 'ISSN' => $borrow_new->ri_issn, 'ISBN' => $borrow_new->ri_isbn, 'EDITORE' => $borrow_new->ri_editore, 'SCOMPENSO' => $dati_forni['bi_scompenso']); + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW")); + + if ($borrow_new->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + } + } else + sendAjaxXML(502, getConstVar("ERR_LIBRARY_NOT_EXIST"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + else + sendAjaxXML(501, getConstVar("ERR_MISSING_LIBRARY"), $errore, null); + } + break; + + case "ripeti_richiedi_fuorinilde": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow_old = unserialize($_SESSION['str_borrow']); + $controllo = $borrow_old->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + + switch ($borrow_old->dd_stato_borr) { + + case getConstVar("BORR_NO_RICEVUTO"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_NO_RIC"); + break; + + case getConstVar("BORR_UTE_RIFIUTA_FN"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_RIFPAG"); + break; + + case getConstVar("BORR_CESTINATO"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_CESTINATO"); + break; + } + $ok = $borrow_old->aggiornaDB(); + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $ddid = $borrow_old->dd_id; + $borrow_new = new Borrowing(null, $borrow_old->ri_tipomateriale, $borrow_old->bi_idrichie); + + $borrow_new->ri_id = $borrow_old->ri_id; + $borrow_new->ut_id = $borrow_old->ut_id; + $borrow_new->rm_countbib = $borrow_old->rm_countbib; + $borrow_new->rm_datarichie = $borrow_old->rm_datarichie; + $borrow_new->dd_polcosti = $borrow_old->dd_polcosti; + $borrow_new->ri_titolopub = $borrow_old->ri_titolopub; + $borrow_new->ri_titolopart = $borrow_old->ri_titolopart; + $borrow_new->ri_au1 = $borrow_old->ri_au1; + $borrow_new->ri_au2 = $borrow_old->ri_au2; + $borrow_new->ri_anno = $borrow_old->ri_anno; + $borrow_new->ri_vol = $borrow_old->ri_vol; + $borrow_new->ri_fasc = $borrow_old->ri_fasc; + $borrow_new->ri_pgini = $borrow_old->ri_pgini; + $borrow_new->ri_pgfine = $borrow_old->ri_pgfine; + + if (isset($_POST["bi_idforni"])) + $borrow_new->bi_idforni = $_POST["bi_idforni"]; + if (isset($_POST["dd_costofuorinilde"])) { + $borrow_new->dd_costofuorinilde = $_POST["dd_costofuorinilde"]; + } + if (isset($_POST["dd_nprotrichie"])) + $borrow_new->dd_nprotrichie = $_POST["dd_nprotrichie"]; + if (isset($_POST["dd_nproteva"])) + $borrow_new->dd_nproteva = $_POST["dd_nproteva"]; + if (isset($_POST["dd_note_interne"])) + $borrow_new->dd_note_interne = $_POST["dd_note_interne"]; + + $borrow_new->dd_stato_borr = getConstVar("BORR_INOLTRATO"); + $borrow_new->dd_stato_ddill = getConstVar("DDILL_INOLT_FN"); + $borrow_new->dd_datarichie = date("Y-m-d H:i:s"); + + $borrow_new->aggiornaObject($_POST); + $ddid = $borrow_new->inserisciDB(); + + $borrow_new->aggiorna_contatore_sett(); + aggiornaReport('ripeti_richie_bw_fn', $borrow_new); + sendAjaxXML(201, getConstVar("MSG_REQUEST_FW"), null, null); + + $resforni = $_SESSION['db']->execute("SELECT bi_nilde,bi_costo_dd,bi_email_dd,bi_scompenso FROM biblio WHERE bi_id=" . $borrow_new->bi_idforni); + $costo = 0; + $emailforni = ""; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_forni = $_SESSION['db']->fetch($resforni); + if ($dati_forni['bi_nilde'] == 0) + $costo = $borrow_new->dd_costofuorinilde; + else + $costo = $dati_forni['bi_costo_dd']; + + $cat_data = isBiblioInCatalog($_SESSION['biblio']->bi_id, 1); + if ($cat_data != null) { + $acnpcod = $cat_data["acnp_cod"]; + } else + $acnpcod = null; + + if ($costo == "0.00") { + $array_dati = array('BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow_new->dd_datarichie, 'NOMERIVISTA' => $borrow_new->ri_titolopub, 'DOI' => $borrow_new->ri_doi, 'TITOLOARTICOLO' => $borrow_new->ri_titolopart, 'AUTORE' => $borrow_new->ri_au1, 'AUTORI' => $borrow_new->ri_au2, 'ANNO' => $borrow_new->ri_anno, 'VOLUME' => $borrow_new->ri_vol, 'FASCICOLO' => $borrow_new->ri_fasc, 'PAGINI' => $borrow_new->ri_pgini, 'PAGFINE' => $borrow_new->ri_pgfine, 'COD' => $acnpcod, 'ISSN' => $borrow_new->ri_issn, 'ISBN' => $borrow_new->ri_isbn, 'EDITORE' => $borrow_new->ri_editore); + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC")); + + if ($borrow_new->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROWSC_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + } else { + $array_dati = array('BIBLIORICHIEDENTE' => $_SESSION['biblio']->bi_nome, 'NUMORDINE' => $ddid, 'bi_costo_dd' => $costo, 'EMAILRICHIEDENTE' => $_SESSION['biblio']->bi_email_dd, 'INDIRIZZORICHIEDENTE' => $_SESSION['biblio']->bi_indi, 'CITTARICHIEDENTE' => $_SESSION['biblio']->bi_citta, 'CAPRICHIEDENTE' => $_SESSION['biblio']->bi_cap, 'TELRICHIEDENTE' => $_SESSION['biblio']->bi_tel, 'FAXRICHIEDENTE' => $_SESSION['biblio']->bi_fax, 'CFRICHIEDENTE' => $_SESSION['biblio']->bi_cf, 'PIVARICHIEDENTE' => $_SESSION['biblio']->bi_piva, 'DATARICHIE' => $borrow_new->dd_datarichie, 'NOMERIVISTA' => $borrow_new->ri_titolopub, 'DOI' => $borrow_new->ri_doi, 'TITOLOARTICOLO' => $borrow_new->ri_titolopart, 'AUTORE' => $borrow_new->ri_au1, 'AUTORI' => $borrow_new->ri_au2, 'ANNO' => $borrow_new->ri_anno, 'VOLUME' => $borrow_new->ri_vol, 'FASCICOLO' => $borrow_new->ri_fasc, 'PAGINI' => $borrow_new->ri_pgini, 'PAGFINE' => $borrow_new->ri_pgfine, 'COD' => $acnpcod, 'ISSN' => $borrow_new->ri_issn, 'ISBN' => $borrow_new->ri_isbn, 'EDITORE' => $borrow_new->ri_editore, 'SCOMPENSO' => $dati_forni['bi_scompenso']); + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW")); + + if ($borrow_new->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL1BORROW_BOOK")); + + if (isset($dati_forni['bi_email_dd'])) { + $testMail = new Mail($dati_forni['bi_email_dd'], $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECTBW") . $ddid, $testMsg); + $testMail->send(); + } + } + } else + sendAjaxXML(502, getConstVar("ERR_LIBRARY_NOT_EXIST"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + elseif (!isset($_POST["bi_idforni"])) + sendAjaxXML(501, getConstVar("ERR_MISSING_LIBRARY"), $errore, null); + else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "ripeti_informa_ute_fn": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow_old = unserialize($_SESSION['str_borrow']); + $controllo = $borrow_old->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + + switch ($borrow_old->dd_stato_borr) { + case getConstVar("BORR_NO_RICEVUTO"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_NO_RIC"); + break; + case getConstVar("BORR_UTE_RIFIUTA_FN"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_RIFPAG"); + break; + case getConstVar("BORR_CESTINATO"): + $borrow_old->dd_stato_borr = getConstVar("BORR_REITERA_CESTINATO"); + break; + } + $ok = $borrow_old->aggiornaDB(); + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $borrow_new = new Borrowing(null, $borrow_old->ri_tipomateriale, $borrow_old->bi_idrichie); + + $borrow_new->ri_id = $borrow_old->ri_id; + $borrow_new->ut_id = $borrow_old->ut_id; + $borrow_new->rm_id = $borrow_old->rm_id; + $borrow_new->rm_datarichie = $borrow_old->rm_datarichie; + $borrow_new->rm_dataeva = $borrow_old->rm_dataeva; + $borrow_new->rm_noteutebib = $borrow_old->rm_noteutebib; + $borrow_new->rm_notebibute = $borrow_old->rm_notebibute; + $borrow_new->rm_polcosti = $borrow_old->rm_polcosti; + $borrow_new->rm_countbib = $borrow_old->rm_countbib; + $borrow_new->dd_polcosti = $borrow_old->dd_polcosti; + + if (isset($_POST["bi_idforni"])) + $borrow_new->bi_idforni = $_POST["bi_idforni"]; + if (isset($_POST["dd_costofuorinilde"])) { + $borrow_new->dd_costofuorinilde = $_POST["dd_costofuorinilde"]; + } + if (isset($_POST["dd_nprotrichie"])) + $borrow_new->dd_nprotrichie = $_POST["dd_nprotrichie"]; + if (isset($_POST["dd_nproteva"])) + $borrow_new->dd_nproteva = $_POST["dd_nproteva"]; + if (isset($_POST["dd_note_interne"])) + $borrow_new->dd_note_interne = $_POST["dd_note_interne"]; + + + $borrow_new->dd_stato_borr = getConstVar("BORR_ATTESA_ACCETTA_UTE_FN"); + $borrow_new->dd_stato_accetta = getConstVar("STATO_ACC_NORISP"); + $borrow_new->rm_stato = getConstVar("Rif_BiblioChiedeConferma"); + + $borrow_new->aggiornaObject($_POST); + + $ok = $borrow_new->inserisciDB(); + + if ($ok) + sendAjaxXML(201, getConstVar("MSG_REFERENCE_INSERT"), null, null); + else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else { + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } + } else { + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } + } elseif (!isset($_POST["bi_idforni"])) + sendAjaxXML(501, getConstVar("ERR_MISSING_LIBRARY"), $errore, null); + else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "cancella_file": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $borrow->elimina_file(); + $borrow->dd_stato_borr = getConstVar("BORR_RICEVUTO"); + + $ok = $borrow->aggiornaDB(); + $borrow = new Borrowing($borrow->dd_id); + $form = new FieldsForm(); + $borrow->reset_controllo(); + $borrow->box_bottoni($form); + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + + $_SESSION['str_borrow'] = serialize($borrow); + sendAjaxXML(201, null, null, $form->restituisci()); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "no_consegna_ute": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $msg = "MSG_OK_ARCHIVED"; + if ($borrow->isUserRequest()) { + if (isset($_POST["rm_notebibute"])) + $borrow->rm_notebibute = $_POST["rm_notebibute"]; + $borrow->rm_stato = getConstVar("Rif_RichiestaChiusa_Ineva"); + $msg = "MSG_OK_ARCHIVED_INEV"; + } + + switch ($borrow->dd_stato_borr) { + + case getConstVar("BORR_NO_RICEVUTO"): + $borrow->dd_stato_borr = getConstVar("BORR_NO_CONS_NO_RIC"); + break; + + case getConstVar("BORR_UTE_RIFIUTA_FN"): + $borrow->dd_stato_borr = getConstVar("BORR_NO_CONS_RIFPAG"); + break; + + case getConstVar("BORR_CESTINATO"): + $borrow->dd_stato_borr = getConstVar("BORR_NO_CONS_CESTINATO"); + break; + + case getConstVar("BORR_UTE_NORISP"): + $borrow->dd_stato_borr = getConstVar("BORR_NO_CONS_DIRETTA"); + break; + + default: + $borrow->dd_stato_borr = getConstVar("BORR_NO_CONS_DIRETTA"); + } + + $borrow->aggiornaObject($_POST); + $ok = $borrow->aggiornaDB(); + if ($ok && $borrow->isUserRequest()) { + if ($borrow->dd_stato_borr == getConstVar("BORR_NO_CONS_DIRETTA")) + aggiornaReport('no_consegna_dir_ute', $borrow); + else + aggiornaReport('no_consegna_ute', $borrow); + } + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + + $resforni = $_SESSION['db']->execute("SELECT u.ut_email,r.rm_countbib FROM utente AS u INNER JOIN refman AS r ON u.ut_id=r.ut_id WHERE r.ri_id=" . $borrow->ri_id); + $emailute = ""; + $id_ordine = 0; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_ute = $_SESSION['db']->fetch($resforni); + $emailute = $dati_ute['ut_email']; + $id_ordine = $dati_ute['rm_countbib']; + if (empty($_POST["rm_notebibute"])) { + $array_dati = array('NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'ISSN' => $borrow->ri_issn, 'ID' => $id_ordine, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore); + $testMsg = new Message($array_dati, getConstVar("MAIL3_INEVASIONE_UTE_NOCOMUNICAZIONI")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL3_INEVASIONE_UTE_NOCOMUNICAZIONI_BOOK")); + + + $testMail = new Mail($emailute, $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECT_INEVASIONE_RICHIESTA") . $id_ordine, $testMsg); + $testMail->send(); + }else { + $array_dati = array('NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'NOTE' => $borrow->rm_notebibute, 'ID' => $id_ordine, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore); + $testMsg = new Message($array_dati, getConstVar("MAIL3_INEVASIONE_UTE_COMUNICAZIONI")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL3_INEVASIONE_UTE_COMUNICAZIONI_BOOK")); + + $testMail = new Mail($emailute, $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECT_INEVASIONE_RICHIESTA") . $id_ordine, $testMsg); + $testMail->send(); + } + } + + sendAjaxXML(201, getConstVar($msg), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "consegna_ute": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $msg = "MSG_OK_ARCHIVED"; + if ($borrow->isUserRequest()) { + if (isset($_POST["rm_notebibute"])) + $borrow->rm_notebibute = $_POST["rm_notebibute"]; + $borrow->rm_stato = getConstVar("Rif_RichiestaChiusa_Eva"); + $msg = "MSG_OK_ARCHIVED_EV"; + } + + if ($borrow->dd_stato_ddill > 0) + $borrow->dd_stato_borr = getConstVar("BORR_CONS"); + else + $borrow->dd_stato_borr = getConstVar("BORR_CONS_DIRETTA"); + +// DIADOSIS TEAM Add HC File upload procedure + if (isset($_POST["dd_file"])) + $borrow->dd_file = $_POST["dd_file"]; + else + $borrow->dd_file = $borrow->dd_id.".pdf"; + + $file = getConstVar("UPLOAD_DIR") . $borrow->dd_file; + $pathinfo = pathinfo($file); + $borrow->dd_stato_file = getConstVar("DD_STATO_FILE_NO_DOWNLOAD"); + + $HCresult = null; + + if (getConstVar('HC_ENABLED') && strtolower($pathinfo["extension"]) == 'pdf') { + $borrow->addCopyRightPage($_SESSION["biblio"]->bi_id); + + + $curl_handle = curl_init(); + curl_setopt($curl_handle, CURLOPT_URL, getConstVar("URL_SERVER_HC") . "?id=" . $borrow->dd_id); + curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); + curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); + + if (strpos(getConstVar("URL_SERVER_HC"), "nilde3.bo.cnr.it") >= 0) + curl_setopt($curl_handle, CURLOPT_USERPWD, "tidp:testidp"); + + $HCresult = curl_exec($curl_handle); + curl_close($curl_handle); + + if ($HCresult == "OK") { + $borrow->aggiornaObject($_POST); + $ok = $borrow->aggiornaDB(); + + if ($ok && $borrow->isUserRequest()) { + if ($borrow->dd_stato_borr == getConstVar("BORR_CONS_DIRETTA")) + aggiornaReport('consegna_dir_ute', $borrow); + else + aggiornaReport('consegna_ute', $borrow); + } + + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + sendAjaxXML(201, getConstVar("MSG_REQ_EV"), null, null); + break; + } else { + sendAjaxXML(501, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + break; + } + } else { + sendAjaxXML(501, $HCresult . " - " . getConstVar("HC_SERVER_DOWN_MSG"), null, null); + break; + } + } + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $resforni = $_SESSION['db']->execute("SELECT u.ut_email,r.rm_countbib FROM utente AS u INNER JOIN refman AS r ON u.ut_id=r.ut_id WHERE r.ri_id=" . $borrow->ri_id); + $emailute = ""; + $id_ordine = 0; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_ute = $_SESSION['db']->fetch($resforni); + $emailute = $dati_ute['ut_email']; + $id_ordine = $dati_ute['rm_countbib']; + if (empty($_POST["rm_notebibute"])) { + $array_dati = array('NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'ID' => $id_ordine, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore); + $testMsg = new Message($array_dati, getConstVar("MAIL3_EVASIONE_UTE_NOCOMUNICAZIONI")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL3_EVASIONE_UTE_NOCOMUNICAZIONI_BOOK")); + + $testMail = new Mail($emailute, $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECT_EVASIONE_RICHIESTA") . $id_ordine, $testMsg); + $testMail->send(); + } else { + $array_dati = array('NOMERIVISTA' => $borrow->ri_titolopub, 'DOI' => $borrow->ri_doi, 'TITOLOARTICOLO' => $borrow->ri_titolopart, 'AUTORE' => $borrow->ri_au1, 'AUTORI' => $borrow->ri_au2, 'ANNO' => $borrow->ri_anno, 'VOLUME' => $borrow->ri_vol, 'FASCICOLO' => $borrow->ri_fasc, 'PAGINI' => $borrow->ri_pgini, 'PAGFINE' => $borrow->ri_pgfine, 'NOTE' => $borrow->rm_notebibute, 'ID' => $id_ordine, 'ISSN' => $borrow->ri_issn, 'ISBN' => $borrow->ri_isbn, 'EDITORE' => $borrow->ri_editore); + $testMsg = new Message($array_dati, getConstVar("MAIL3_EVASIONE_UTE_COMUNICAZIONI")); + + if ($borrow->ri_tipomateriale == getConstVar('TIPO_LIBRO')) + $testMsg = new Message($array_dati, getConstVar("MAIL3_EVASIONE_UTE_COMUNICAZIONI_BOOK")); + + $testMail = new Mail($emailute, $_SESSION['biblio']->bi_email_dd, getConstVar("SUBJECT_EVASIONE_RICHIESTA") . $id_ordine, $testMsg); + $testMail->send(); + } + } + sendAjaxXML(201, getConstVar($msg), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "evasione_FN": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $_POST['dd_dataeva_ore'] = date('H'); + $_POST['dd_dataeva_min'] = date('i'); + $_POST['dd_dataeva_sec'] = date('s'); + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $borrow->set_parse("dd_dataeva", $_POST); + $errore = ControlloCampi::check_dataeva($borrow->dd_dataeva, $borrow->dd_datarichie); + + if ($errore == null) { + + if ($_POST["eva"] == "evaso") { + $borrow->dd_stato_borr = getConstVar("BORR_RICEVUTO"); + $borrow->dd_stato_ddill = getConstVar("DDILL_EVASO_FN"); + } elseif ($_POST["eva"] == "inevaso") { + $borrow->dd_stato_borr = getConstVar("BORR_NO_RICEVUTO"); + $borrow->dd_stato_ddill = getConstVar("DDILL_INEVASO_FN"); + } + + $borrow->aggiornaObject($_POST); + $ok = $borrow->aggiornaDB(); + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + + $borrow = new Borrowing($borrow->dd_id); + + $form = new FieldsForm("form_richiesta"); + $borrow->reset_controllo(); + + if ($_POST["eva"] == "evaso") + $borrow->box_riferimento_visualizza($form); + else + $borrow->box_riferimento_edit($form); + + $borrow->box_bottoni($form); + $_SESSION['str_borrow'] = serialize($borrow); + sendAjaxXML(201, null, $errore, $form->restituisci()); + aggiornaReport('evasione_FN', $borrow); + } else { + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_DATE"), $errore, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "cestina": + if (!isset($_SESSION['str_borrow'])) { + sendAjaxXML(555, getConstVar('ERR_INVALID_REQUEST_SESSION'), null, null); + } else { + $borrow = unserialize($_SESSION['str_borrow']); + $controllo = $borrow->get_controllo(); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $borrow->dd_stato_borr = getConstVar("BORR_CESTINATO"); + $ok = $borrow->aggiornaDB(); + + if ($ok) { + if ((int) $ok != getConstVar("ERROR_LASTMODIFY")) { + $borrow = new Borrowing($borrow->dd_id); + $res = $borrow->box_bottoni_chiusura(TRUE); + $form = new FieldsForm("form_richiesta"); + $borrow->reset_controllo(); + $borrow->box_riferimento_edit($form); + $borrow->box_bottoni($form); + $res.=$form->restituisci(); + $_SESSION['str_borrow'] = serialize($borrow); + aggiornaReport('cestina', $borrow); + sendAjaxXML(201, null, $errore, $res); + } else + sendAjaxXML(502, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + } +} +?> + diff --git a/action_refman.php b/action_refman.php new file mode 100755 index 0000000..75e0e5b --- /dev/null +++ b/action_refman.php @@ -0,0 +1,365 @@ +visualizza(); + //ricarico l'ogg in sessione coi dati aggiornati + $_SESSION['str_rm'] = serialize($rm); + } + break; + + case 'openByOpenurl': + //lo fa aprire solo se non esiste un rif aperto in MODIFICA + if (isset($_SESSION) && isset($_SESSION['str_rm_edit'])) { + sendAjaxXML(501, getConstVar('ERR_ALREADY_OPENED_REQUEST'), null, null); + } else { + ////assegno a versione la versione appropriata + $versione = findVer(); + //assegno a tipo il tipo appropriato + if ($versione == "Z39.88-2004") { + $tipo = typeFinder10(); + } elseif ($versione == null) { + $tipo = typeFinder01(); + } elseif ($versione == "pubmed") { + $tipo = getConstVar("TIPO_ARTICOLO"); + } + //QUA CHIAMO UTLITY||||||||||||| PER TIPO ARTICOLO E TIPO OPEN URL + $rm = new Refman(null, $tipo, $_SESSION['utente']->ut_id); + + //metto in sessione il fatto che ho in EDIT un riferimento cosi' mi blocca l'apertura di altre richieste nuove o da openurl + $_SESSION['str_rm_edit'] = $rm->ri_id; + // $rm->nuovo_openurl_old($_GET); + $rm->nuovo_openurl($tipo); + $_SESSION['str_rm'] = serialize($rm); + } + break; + + case "new_rif": + if (isset($_SESSION) && isset($_SESSION['str_rm_edit'])) + sendAjaxXML(501, getConstVar('ERR_ALREADY_OPENED_REQUEST'), null, null); + else { + + if (!isset($_GET["tipomat"])) { + echo "
"; + echo" + + + + \"\" + + " . getConstVar("ACNP_PROSEGUI") . " + + \"\" + +

+ "; + echo "

" . getConstVar("SEARCH_TO_HEAL_PORTAL") . "

\n"; + echo "
\n"; + } else { + $_GET["tipomat"] = strip_tags($_GET["tipomat"]); + $rm = new Refman(null, $_GET["tipomat"], $_SESSION['utente']->ut_id); + $_SESSION['str_rm_edit'] = $rm->ri_id; + $rm->nuovo_doi(); + $_SESSION['str_rm'] = serialize($rm); + } + } + break; + + case "new_rif_openurl": + if (isset($_SESSION) && isset($_SESSION['str_rm_edit'])) + sendAjaxXML(501, getConstVar('ERR_ALREADY_OPENED_REQUEST'), null, null); + else { + $versione = findVer(); + if ($versione == "Z39.88-2004") { + $tipo = typeFinder10(); + } elseif ($versione == null) { + $tipo = typeFinder01(); + } elseif ($versione == "pubmed") { + $tipo = getConstVar("TIPO_ARTICOLO"); + } + $rm = new Refman(null, $tipo, $_SESSION['utente']->ut_id); + $_SESSION['str_rm_edit'] = $rm->ri_id; + $rm->nuovo_openurl($_GET); + } + break; + + case "ric_rif": + if (isset($_SESSION) && isset($_SESSION['str_rm_edit'])) { + sendAjaxXML(501, getConstVar('ERR_ALREADY_OPENED_REQUEST'), null, null); + } else { + $rid = $_REQUEST["rid"]; + $rm = new Refman($rid, null, $_SESSION['utente']->ut_id); + $rm->modifica(TRUE); // Parametri: Richiesta + $rm->aggiornaObject($_POST); + $_SESSION['str_rm'] = serialize($rm); + $_SESSION['str_rm_edit'] = $rm->ri_id; + } + break; + + + case "save": + $rm = unserialize($_SESSION['str_rm']); + $controllo = unserialize(urldecode($_POST["controllo"])); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $rifid = $rm->inserisci($_POST, false); + if ($rifid) { + $rm->aggiornaObject($_POST); + $rm = new Refman($rifid); + + $_SESSION['str_rm'] = serialize($rm); + sendAjaxXML(203, getConstVar("MSG_REFERENCE_INSERT"), null, $rm->visualizza()); + clean_refman_session(); + } else + sendAjaxXML(502, getConstVar("ERR_UPDATE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + + break; + + case "save_req": + $rm = unserialize($_SESSION['str_rm']); + $controllo = unserialize(urldecode($_POST["controllo"])); + $sospdate = getSospensioneDD($_SESSION['bib_app']); + if (checkSospensioneDD(date("Y-m-d"), $sospdate) || !biblioIsActive($_SESSION['bib_app'])) { + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $rifid = $rm->inserisci($_POST, false); + if ($rifid) { + $rm->aggiornaObject($_POST); + $rm = new Refman($rifid); + + $_SESSION['str_rm'] = serialize($rm); + clean_refman_session(); + sendAjaxXML(505, getConstVar("ERR_NORICH_SOSPDD"), null, $rm->visualizza()); + } else { + clean_refman_session(); + sendAjaxXML(502, getConstVar("ERR_UPDATE"), null, null); + } + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + else { + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $errore_richie = ControlloCampi::check_richiesta($_POST, $rm->ri_tipomateriale); + if (!$errore_richie) { + $rifid = $rm->inserisci($_POST, true); + if ($rifid) { + $rm->aggiornaObject($_POST); + $_SESSION['str_rm'] = serialize($rm); + $rm = new Refman($rifid); + $resbiblio = $_SESSION['db']->execute("SELECT bi_nome,bi_email_dd FROM biblio WHERE bi_id=" . $_SESSION['bib_app']); + $nomebiblio = ""; + $emailbiblio = ""; + if ($resbiblio && $_SESSION['db']->numrows($resbiblio) == 1) { + $dati_biblio = $_SESSION['db']->fetch($resbiblio); + $emailbiblio = $dati_biblio['bi_email_dd']; + $nomebiblio = $dati_biblio['bi_nome']; + $resforni = $_SESSION['db']->execute("SELECT rm_countbib FROM refman WHERE ri_id='$rifid'"); + $id_ordine = 0; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_ute = $_SESSION['db']->fetch($resforni); + $id_ordine = $dati_ute['rm_countbib']; + $array_dati = array('NOMERIVISTA' => $rm->ri_titolopub, 'DOI' => $rm->ri_doi, 'TITOLOARTICOLO' => $rm->ri_titolopart, 'AUTORE' => $rm->ri_au1, 'AUTORI' => $rm->ri_au2, 'ANNO' => $rm->ri_anno, 'VOLUME' => $rm->ri_vol, 'FASCICOLO' => $rm->ri_fasc, 'PAGINI' => $rm->ri_pgini, 'PAGFINE' => $rm->ri_pgfine, 'BIBLIO' => $nomebiblio, 'NOTE' => $rm->rm_noteutebib, 'ID' => $id_ordine, 'ISSN' => $rm->ri_issn, 'ISBN' => $rm->ri_isbn, 'EDITORE' => $rm->ri_editore); + $array_dati_biblio = array('LASTDD_ID' => $_SESSION['lastdd_id'], 'UTNOME' => $_SESSION['utente']->ut_nome, 'UTCOGNOME' => $_SESSION['utente']->ut_cognome, 'NOMERIVISTA' => $rm->ri_titolopub, 'DOI' => $rm->ri_doi, 'TITOLOARTICOLO' => $rm->ri_titolopart, 'AUTORE' => $rm->ri_au1, 'AUTORI' => $rm->ri_au2, 'ANNO' => $rm->ri_anno, 'VOLUME' => $rm->ri_vol, 'FASCICOLO' => $rm->ri_fasc, 'PAGINI' => $rm->ri_pgini, 'PAGFINE' => $rm->ri_pgfine, 'NOTE' => $rm->rm_noteutebib, 'ID' => $id_ordine, 'ISSN' => $rm->ri_issn, 'ISBN' => $rm->ri_isbn, 'EDITORE' => $rm->ri_editore); + unset($_SESSION['lastdd_id']); + $testMsg = new Message($array_dati, getConstVar("MAIL4_UTENTE")); + $testMsgBiblio = new Message($array_dati_biblio, getConstVar("MAIL4_BIBLIO")); + if ($rm->ri_tipomateriale == getConstVar('TIPO_LIBRO')) { + $testMsg = new Message($array_dati, getConstVar("MAIL4_UTENTE_BOOK")); + $testMsgBiblio = new Message($array_dati_biblio, getConstVar("MAIL4_BIBLIO_BOOK")); + } + + + $testMail = new Mail($_SESSION['utente']->ut_email, $emailbiblio, getConstVar("SUBJECTUT") . $id_ordine, $testMsg); + $testMail->send(); + $testMailBiblio = new Mail($emailbiblio, $_SESSION['utente']->ut_email, getConstVar("SUBJECTUT") . $id_ordine, $testMsgBiblio); + $testMailBiblio->send(); + sendAjaxXML(207, getConstVar("MSG_REFERENCE_REQUEST"), null, $rm->visualizza()); + } + } + aggiornaReport('nuova_richie_ute', $rm); + clean_refman_session(); + } else + sendAjaxXML(502, getConstVar("ERR_SAVE"), null, null); + } else + sendAjaxXML(504, getConstVar("ERR_REFERENCE_REQUEST_INCOMPLETE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + + case "update": + $rm = unserialize($_SESSION['str_rm']); + $controllo = unserialize(urldecode($_POST["controllo"])); + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $rifid = $rm->aggiorna($_POST, false); + if ($rifid) { + $rm->aggiornaObject($_POST); + $_SESSION['str_rm'] = serialize($rm); + + sendAjaxXML(201, getConstVar("MSG_REFERENCE_UPDATE"), null, $rm->visualizza()); + clean_refman_session(); + } else { + clean_refman_session(); + sendAjaxXML(502, getConstVar("ERR_UPDATE"), null, $rm->visualizza()); + } + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + + break; + + case "update_req": + $rm = unserialize($_SESSION['str_rm']); + $controllo = unserialize(urldecode($_POST["controllo"])); + + $sospdate = getSospensioneDD($_SESSION['bib_app']); + if (checkSospensioneDD(date("Y-m-d"), $sospdate) || !biblioIsActive($_SESSION['bib_app'])) { + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $rifid = $rm->aggiorna($_POST, false); + if ($rifid) { + $rm->aggiornaObject($_POST); + $_SESSION['str_rm'] = serialize($rm); + clean_refman_session(); + sendAjaxXML(505, getConstVar("ERR_NORICH_SOSPDD"), null, $rm->visualizza()); + } else { + clean_refman_session(); + sendAjaxXML(502, getConstVar("ERR_UPDATE"), null, $rm->visualizza()); + } + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + else { + + $errore = ControlloCampi::check_all($_POST, $controllo); + if ($errore == null) { + $errore_richie = ControlloCampi::check_richiesta($_POST, $rm->ri_tipomateriale); + if (!$errore_richie) { + if ($rm->aggiorna($_POST, true)) { + $rm->aggiornaObject($_POST); + $_SESSION['str_rm'] = serialize($rm); + $rm = new Refman($_POST["ri_id"]); + + $resbiblio = $_SESSION['db']->execute("SELECT bi_nome,bi_email_dd FROM biblio WHERE bi_id=" . $_SESSION['bib_app']); + $nomebiblio = ""; + $emailbiblio = ""; + if ($resbiblio && $_SESSION['db']->numrows($resbiblio) == 1) { + $dati_biblio = $_SESSION['db']->fetch($resbiblio); + $emailbiblio = $dati_biblio['bi_email_dd']; + $nomebiblio = $dati_biblio['bi_nome']; + + $resforni = $_SESSION['db']->execute("SELECT rm_countbib FROM refman WHERE ri_id='$rm->ri_id'"); + $id_ordine = 0; + if ($resforni && $_SESSION['db']->numrows($resforni) == 1) { + $dati_ute = $_SESSION['db']->fetch($resforni); + $id_ordine = $dati_ute['rm_countbib']; + $array_dati = array('NOMERIVISTA' => $rm->ri_titolopub, 'DOI' => $rm->ri_doi, 'TITOLOARTICOLO' => $rm->ri_titolopart, 'AUTORE' => $rm->ri_au1, 'AUTORI' => $rm->ri_au2, 'ANNO' => $rm->ri_anno, 'VOLUME' => $rm->ri_vol, 'FASCICOLO' => $rm->ri_fasc, 'PAGINI' => $rm->ri_pgini, 'PAGFINE' => $rm->ri_pgfine, 'BIBLIO' => $nomebiblio, 'NOTE' => $rm->rm_noteutebib, 'ID' => $id_ordine, 'ISSN' => $rm->ri_issn, 'ISBN' => $rm->ri_isbn, 'EDITORE' => $rm->ri_editore); + $array_dati_biblio = array('LASTDD_ID' => $_SESSION['lastdd_id'], 'UTNOME' => $_SESSION['utente']->ut_nome, 'UTCOGNOME' => $_SESSION['utente']->ut_cognome, 'NOMERIVISTA' => $rm->ri_titolopub, 'DOI' => $rm->ri_doi, 'TITOLOARTICOLO' => $rm->ri_titolopart, 'AUTORE' => $rm->ri_au1, 'AUTORI' => $rm->ri_au2, 'ANNO' => $rm->ri_anno, 'VOLUME' => $rm->ri_vol, 'FASCICOLO' => $rm->ri_fasc, 'PAGINI' => $rm->ri_pgini, 'PAGFINE' => $rm->ri_pgfine, 'NOTE' => $rm->rm_noteutebib, 'ID' => $id_ordine, 'ISSN' => $rm->ri_issn, 'ISBN' => $rm->ri_isbn, 'EDITORE' => $rm->ri_editore); + unset($_SESSION['lastdd_id']); + $testMsg = new Message($array_dati, getConstVar("MAIL4_UTENTE")); + $testMsgBiblio = new Message($array_dati_biblio, getConstVar("MAIL4_BIBLIO")); + + if ($rm->ri_tipomateriale == getConstVar('TIPO_LIBRO')) { + $testMsg = new Message($array_dati, getConstVar("MAIL4_UTENTE_BOOK")); + $testMsgBiblio = new Message($array_dati_biblio, getConstVar("MAIL4_BIBLIO_BOOK")); + } + + $testMail = new Mail($_SESSION['utente']->ut_email, $emailbiblio, getConstVar("SUBJECTUT") . $id_ordine, $testMsg); + $testMail->send(); + $testMailBiblio = new Mail($emailbiblio, $_SESSION['utente']->ut_email, getConstVar("SUBJECTUT") . $id_ordine, $testMsgBiblio); + $testMailBiblio->send(); + sendAjaxXML(207, getConstVar("MSG_REFERENCE_REQUEST"), null, $rm->visualizza()); + } + } + + aggiornaReport('nuova_richie_ute', $rm); + clean_refman_session(); + } else { + clean_refman_session(); + sendAjaxXML(502, getConstVar("ERR_UPDATE"), null, $rm->visualizza()); + } + } else + sendAjaxXML(504, getConstVar("ERR_REFERENCE_REQUEST_INCOMPLETE"), null, null); + } else + sendAjaxXML(501, getConstVar("ERR_REFERENCE_INCOMPLETE"), $errore, null); + } + break; + + case "edit": + $rm = unserialize($_SESSION['str_rm']); + $_SESSION['str_rm_edit'] = $rm->ri_id; + $rm->modifica(); + $rm->aggiornaObject($_POST); + $_SESSION['str_rm'] = serialize($rm); + break; + + case "rispostaFN": + $rm = unserialize($_SESSION['str_rm']); + $rm->rispostaFN($_GET["risp"]); + echo $rm->visualizza_dati_dd(); + $rm->aggiornaObject($_GET); + $_SESSION['str_rm'] = serialize($rm); + + clean_refman_session(); + + $resbiblio = $_SESSION['db']->execute("SELECT bi_email_dd FROM biblio WHERE bi_id=" . $_SESSION['bib_app']); + $emailbiblio = ""; + if ($resbiblio && $_SESSION['db']->numrows($resbiblio) == 1) { + $dati_biblio = $_SESSION['db']->fetch($resbiblio); + $emailbiblio = $dati_biblio['bi_email_dd']; + $ddID = $_SESSION['db']->fetch_single($_SESSION['db']->execute("SELECT MAX(dd_id) FROM docdel WHERE ut_id=" . $_SESSION['utente']->ut_id . " AND ri_id=" . $rm->ri_id)); + $array_dati = array('ID' => $ddID, 'UTNOME' => $_SESSION['utente']->ut_nome, 'UTCOGNOME' => $_SESSION['utente']->ut_cognome); + if (isset($_GET["risp"]) && $_GET["risp"] == "accetta") { + $testMsg = new Message($array_dati, getConstVar("MAIL10_ACCETTACOSTO")); + $testMail = new Mail($emailbiblio, $_SESSION['utente']->ut_email, getConstVar("SUBJECTINFORMACOSTO") . $rm->rm_countbib, $testMsg); + $testMail->send(); + } else { + $testMsg = new Message($array_dati, getConstVar("MAIL11_RIFIUTACOSTO")); + $testMail = new Mail($emailbiblio, $_SESSION['utente']->ut_email, getConstVar("SUBJECTINFORMACOSTO") . $rm->rm_countbib, $testMsg); + $testMail->send(); + } + } + break; + + case "delete": + $obj_ref = new RefMan($_GET["id"]); + $obj_ref->elimina(); + echo Bibliografia::elenco_rif($_SESSION['utente']->ut_id, $_SESSION['label'], $_SESSION['order'], $_SESSION['qualif'], $_SESSION['start'], $_SESSION['passo'], 0); + break; + } +} diff --git a/action_register_ute.php b/action_register_ute.php new file mode 100755 index 0000000..847f0a2 --- /dev/null +++ b/action_register_ute.php @@ -0,0 +1,267 @@ +"; + + + for ($i=1; $i<=4; $i++) { + + if ($i!=1) { + if ($i <= $step) echo "
"; + else echo ""; + } + + if ($i <= $step /*&& $step < 4*/) + echo "
".$i."
"; + else + echo "
".$i."
"; + } + + echo ""; +} + + +function print_step_page($step,$error=NULL) { + + global $nuovoute; + + $error="
"; + + echo"
"; + switch ($step) { + + case "1": + menu_nav($step); + echo "
+
+

+
".getConstVar("REG_UTE_SEL_CRED")."
+

+ "; + echo $error; + $nuovoute->registra($step); + break; + + case "2": + menu_nav($step); + $nuovoute->registra("vis1"); + echo "
+
+

+ ".getConstVar("REG_UTE_SEL_BIB")." +
+
+ ".getConstVar("REG_UTE_SEL_BIB_2")." +

+ "; + echo $error; + $nuovoute->registra($step); + break; + + case "3": + menu_nav($step); + $nuovoute->registra("vis2"); + echo "
+
+

+ ".getConstVar("REG_UTE_SEL_DATI")." +

+ "; + echo $error; + $nuovoute->registra($step); + break; + + case "4": + $nuovoute->inserisci(); + menu_nav(4); + $nuovoute->registra("vis3"); + echo $error; + echo " +
+

+ ".getConstVar("MSG_REG_UTE_COMPLETE")." +

+
+

+ < ".getConstVar("BACK_TO2")." Home +

+ "; + break; + } + echo " +
+
+ "; + +} + +/*--- MAIN ---*/ + + if(isset($op)) { + + $dbnilde=new Db(); + + switch($op) { + + case "filterInst": + $query=" SELECT en_id,en_nome + FROM ente + WHERE ti_id = ".$_POST["inst_type_select"]." + AND en_id<>".getConstVar('ID_AUTHORG')." + ORDER BY en_nome"; + + $result=$dbnilde->execute($query); + echo ""; + while ($row=$dbnilde->fetch($result)) + echo ""; + break; + + case "filterLibrary": + $html="

"; + + switch ($_POST["radio_sel"]) { + + case "1": + $query=" SELECT bi_id,bi_nome + FROM biblio + WHERE prov_id='".$_POST["loc_select"]."' + ORDER BY bi_nome + "; + break; + + case "2": + $query=" SELECT bi_id,bi_nome + FROM biblio + WHERE biblio.en_id = ".$_POST["inst_select"]." + ORDER BY bi_nome + "; + break; + + case "3": + $query=" SELECT bi_id,bi_nome + FROM biblio + WHERE bi_nome LIKE '%".$_POST["term"]."%' + ORDER BY bi_nome + "; + break; + } + $html.="

+
+ + "; + + $html.=getConstVar("REG_UTE_SEL_BIB_LISTABIB_1"); + + $result=$dbnilde->execute($query); + + $numbib = $dbnilde->numrows($result); + + if ($numbib == 1) $html.=$numbib." ".getConstVar("REG_UTE_SEL_BIB_LISTABIB_2_SING").".
"; + else $html.=$numbib." ".getConstVar("REG_UTE_SEL_BIB_LISTABIB_2_PLUR").".
"; + + if($numbib>0) + + $html.="
"; + + while ($row=$dbnilde->fetch($result)) + $html.="".$row["bi_nome"]."
"; + + $html.="
+ "; + if($numbib>0) + $html.=Form::getButton("btn_forward",getConstVar(CHOOSE_CONTINUE)." >","onclick=\"javascript:reg_step(3)\"","","\n"); + + echo $html; + + break; + } + } + else + switch ($reg) { + + case "1": + $nuovoute->parseandsave($_POST); + + $lista=$nuovoute->controlla_campi_reg($_POST); + if($lista==null) + { + + if ($nuovoute->control_usr($_POST["ut_usr"])) { + + $lista=$nuovoute->conferma_pwd($_POST); + if($lista==null) + print_step_page($nextStep); + else + sendAjaxXMLResponse(503,$lista); + } + else + sendAjaxXMLResponse(502); + } + else + sendAjaxXMLResponse(501,$lista); + + break; + + + + case "2": + + if ($nextStep==1) { + if (isset($_POST["idbib"])) $idbib=$_POST["idbib"]; + print_step_page(1); + } + + elseif ($nextStep==2) { + unset($idbib); + print_step_page(2); + } + + elseif ($nextStep==3) { + if (isset($_POST["idbib"])) $idbib=$_POST["idbib"]; + if (isset($idbib)) print_step_page(3); + else + sendAjaxXMLResponse(504); + } + + break; + + + + case "3": + $nuovoute->parseandsave($_POST); + + if ($nextStep==4) { + $lista=$nuovoute->controlla_campi_reg($_POST); + if($lista==null) + print_step_page(4); + else + sendAjaxXMLResponse(501,$lista); + } + + else print_step_page($nextStep); + + break; + + + + default: + $nuovoute=new Utente(); + $_SESSION["nuovoute"]=$nuovoute; + + if (isset($_GET["idbib"])) $idbib=$_GET["idbib"]; + elseif (isset($_POST["idbib"])) $idbib=$_GET["idbib"]; + else $idbib=NULL; + + $_SESSION["idbib"]=$idbib; + print_step_page(1); + } + + + + +?> diff --git a/error.php b/error.php new file mode 100755 index 0000000..c3c024a --- /dev/null +++ b/error.php @@ -0,0 +1,74 @@ + + + + + <?php echo $NILDE_EXT; ?> + + + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + + + + + diff --git a/footer_nav.php b/footer_nav.php new file mode 100755 index 0000000..efe5de9 --- /dev/null +++ b/footer_nav.php @@ -0,0 +1,3 @@ +
+ +
diff --git a/google.php b/google.php new file mode 100644 index 0000000..89f0c37 --- /dev/null +++ b/google.php @@ -0,0 +1,10 @@ + + diff --git a/home_footer.php b/home_footer.php new file mode 100755 index 0000000..a4c11c1 --- /dev/null +++ b/home_footer.php @@ -0,0 +1,13 @@ + + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100755 index 0000000..e85a11d --- /dev/null +++ b/index.php @@ -0,0 +1,54 @@ + + + + + <?php echo $NILDE_EXT; ?> + + + + + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/js_header.php b/js_header.php new file mode 100755 index 0000000..7546e5a --- /dev/null +++ b/js_header.php @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/langbar.php b/langbar.php new file mode 100755 index 0000000..83826a5 --- /dev/null +++ b/langbar.php @@ -0,0 +1,12 @@ +

+0)) + { + foreach($langs as $k=>$l) + { + echo "\"$l\"  "; + } + } +?> +

diff --git a/logout.php b/logout.php new file mode 100755 index 0000000..86ead8d --- /dev/null +++ b/logout.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/main_nav.php b/main_nav.php new file mode 100755 index 0000000..35070ca --- /dev/null +++ b/main_nav.php @@ -0,0 +1,23 @@ + + diff --git a/modules/.DS_Store b/modules/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/modules/.DS_Store differ diff --git a/modules/biblio.php b/modules/biblio.php new file mode 100755 index 0000000..df8a19f --- /dev/null +++ b/modules/biblio.php @@ -0,0 +1,1881 @@ +bib = $_SESSION['db']->fetch_fields("biblio"); + $this->bi_pwd_2 = clone $this->bib["bi_pwd"]; + $this->bi_pwd_2->fieldname = 'bi_pwd_2'; + if ($id != null) { + $catlist = ""; + $resc = $_SESSION['db']->execute("SELECT ca_id FROM gruppo_catalogo WHERE gr_id IN (SELECT gr_id from biblio_gruppo WHERE bi_id=" . $id . ")"); + if ($resc && $_SESSION['db']->numrows($resc) > 0) { + while ($c = $_SESSION['db']->fetch($resc)) { + if ($catlist != "") + $catlist.=","; + $catlist.=$c["ca_id"]; + } + if ($catlist != "") + $catlist = "WHERE ca_id IN ($catlist)"; + } + + $res = $_SESSION['db']->execute("SELECT * FROM biblio WHERE bi_id=" . $id); + + if ($res && $_SESSION['db']->numrows($res) == 1) { + $dati = $_SESSION['db']->fetch($res); + foreach ($this->bib as $key => $v) { + $this->bib[$key]->value = $dati[$key]; + } + } + $tente = $_SESSION['db']->execute("SELECT ti_id FROM ente WHERE en_id=" . $this->bib["en_id"]->value); + $this->tipo_ente = $_SESSION["db"]->fetch_single($tente); + $this->progetti = array(); + $res_prog = $_SESSION['db']->execute("SELECT pr_id, pr_nome +FROM progetto +WHERE pr_id IN (SELECT pr_id +FROM biblio_progetto +WHERE bi_id=" . $id . ")"); + while ($row = $_SESSION['db']->fetch($res_prog)) { + $this->progetti[$row["pr_id"]] = $row["pr_nome"]; + } + $nameview = "biblioview_" . rand(0, 999999); + $result_VISTA = $_SESSION['db']->execute("CREATE VIEW biblio_catalogo_" . $nameview . " AS +SELECT ca_id as idcat, bc_attivo +FROM biblio_catalogo +WHERE bi_id =" . $id . ""); + $result_allcat = $_SESSION['db']->execute("SELECT * +FROM catalogo LEFT JOIN biblio_catalogo_" . $nameview . " +ON catalogo.ca_id = biblio_catalogo_" . $nameview . ".idcat $catlist"); + $result_DROPVISTA = $_SESSION['db']->execute("DROP VIEW IF EXISTS biblio_catalogo_" . $nameview); + while ($row = $_SESSION['db']->fetch($result_allcat)) { + $key_cat = $row["ca_id"]; + $this->DATAcat[$key_cat]["ca_nome"] = $row["ca_nome"]; + $this->DATAcat[$key_cat]["bc_attivo"] = $row["bc_attivo"]; + if ($this->DATAcat[$key_cat]["bc_attivo"] === NULL) + $this->DATAcat[$key_cat]["partecipa"] = FALSE; + else + $this->DATAcat[$key_cat]["partecipa"] = TRUE; + + $this->DATAcat[$key_cat]["ca_tabella"] = $row["ca_tabella"]; + if ($this->DATAcat[$key_cat]["ca_tabella"] != NULL) { + $this->DATAcat[$key_cat]["tabella"] = $_SESSION['db']->fetch_fields($row["ca_tabella"]); + $res_tab = $_SESSION['db']->execute("SELECT * FROM " . $row["ca_tabella"] . " WHERE bi_id=" . $id); + $dati_tab = $_SESSION['db']->fetch($res_tab); + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + $this->DATAcat[$key_cat]["tabella"][$key_tab]->value = $dati_tab[$key_tab]; + } + if ($key_cat == 2) { + if ($this->DATAcat[$key_cat]["tabella"]['sbn_cod']->value != "" && $this->DATAcat[$key_cat]["tabella"]['sbn_cod_polo']->value != "") + $this->DATAcat[$key_cat]["partecipa"] = TRUE; + else + $this->DATAcat[$key_cat]["partecipa"] = FALSE; + } + } + else + $this->DATAcat[$key_cat]["tabella"] = NULL; + + $this->DATAcat[$key_cat]["ca_url"] = $row["ca_url"]; + } + + $this->en_arr=array(); + $res_ente=$_SESSION['db']->execute("SELECT en_nome as ente +FROM ente +WHERE en_id=".$this->bib["en_id"]->value); + $ente = $_SESSION['db']->fetch_row($res_ente,0); + $this->en_arr[$this->bib["en_id"]->value] = $ente['ente']; + + $this->nation_arr[$this->bib["na_id"]->value] = $this->bib["na_id"]->value; + $this->prov_arr = db_elenco("prov_id", "na_id='" . $this->bib["na_id"]->value. "'"); + } + else { + $catlist=""; + $resc=$_SESSION['db']->execute("SELECT ca_id FROM gruppo_catalogo WHERE gr_id=1"); + if($resc && $_SESSION['db']->numrows($resc)>0) { + while ($c=$_SESSION['db']->fetch($resc)) { + if($catlist!="") $catlist.=","; + $catlist.=$c["ca_id"]; + } + if($catlist!="") $catlist="WHERE ca_id IN ($catlist)"; + } + $result_allcat = $_SESSION['db']->execute("SELECT * FROM catalogo $catlist"); + while ($row = $_SESSION['db']->fetch($result_allcat)) { + $key = $row["ca_id"]; + $nome_cat = $row["ca_nome"]; + $tabella_cat = $row["ca_tabella"]; + $url_cat = $row["ca_url"]; + + $this->DATAcat[$key]["ca_nome"] = $nome_cat; + $this->DATAcat[$key]["bc_attivo"] = 0; + $this->DATAcat[$key]["partecipa"] = FALSE; + $this->DATAcat[$key]["ca_tabella"] = $tabella_cat; + if ($this->DATAcat[$key]["ca_tabella"] != NULL) + $this->DATAcat[$key]["tabella"] = $_SESSION['db']->fetch_fields($tabella_cat); + else + $this->DATAcat[$key]["tabella"] = NULL; + } + $this->prog_arr = db_elenco("pr_id"); + $this->bib["bi_opac"]->isnull = FALSE; + } + + $this->biblio_account_fields = array($this->bib["bi_usr"], $this->bib["bi_pwd"], $this->bib["bi_nome"], $this->bib["di_id"], $this->bib["en_id"], $this->bib["bi_indi"], $this->bib["bi_cap"], $this->bib["bi_citta"], $this->bib["na_id"], $this->bib["prov_id"], $this->bib["bi_piva"], $this->bib["bi_cf"], $this->bib["bi_tel"], $this->bib["bi_fax"], $this->bib["bi_url"]); + $this->biblio_service_fields = array($this->bib["bi_referente_dd"], $this->bib["bi_email_dd"], $this->bib["bi_tel_dd"], $this->bib["bi_costo_ute_dd"], $this->bib["bi_costo_dd"], $this->bib["bi_scompenso"], $this->bib["bi_condforni"], $this->bib["bi_sospini"], $this->bib["bi_sospfine"], $this->bib["bi_preavvisososp"]); + } + + public function __get($fieldname) { + return $this->bib[$fieldname]->value; + } + + public function get_controllo() { + return $this->controllo; + } + + public function get_tipoEnte() { + return $this->tipo_ente; + } + + public function get_bib() { + return $this->bib; + } + + public function reset_controllo() { + $this->controllo = array(); + } + + public function set_controllo($ctrl) { + $this->controllo = $ctrl; + } + + public function set_bib($bib) { + $this->bib = $bib; + } + + public function __set($fieldname, $val) { + $this->bib[$fieldname]->value = $val; + } + + public function __isset($fieldname) { + return isset($this->bib[$fieldname]); + } + + public function __unset($fieldname) { + unset($this->bib[$fieldname]); + } + + function __toString() { + return "Biblioteca: " . $this->bib["bi_id"]->value . " | " . $this->bib["bi_nome"]->value; + } + + public function registra($step) { + $this->reset_controllo(); + $res = ""; + switch ($step) { + case 1: + $res.=" +
+
+
+
+
+
+
+
+
+
+
"; + $res.=printNavBar("registration_library"); + $res.="
+
+
+
+
"; + $res.=getConstVar("LIBRARYREG"); + $res.="
+
+
+
+"; + $res.=$this->reg_nav($step); + $res.=" +
+
+"; + $res.=$this->reg_passo($step); + + $res.=" +
+
+
+
+
+
+
+
+
+
+
+
+
+"; + break; + + case 6: + $res.=" +
+
+
+
+
+
+
+
+
+
+
"; + if (!$this instanceof BiblioSubscription) + $res.=printNavBar("registration_library"); + else + $res.=printNavBar("subscription_library"); + + $res.="
+
+
+
+
"; + if (!$this instanceof BiblioSubscription) + $res.=getConstVar("LIBRARYREG"); + else + $res.=getConstVar("LIBRARYSUB"); + $res.="
+
+
+"; + $res.=$this->reg_passo($step); + + $res.=" +
+"; + $res.=$this->reg_notifica($step); + + $res.=" +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+"; + break; + + default: + + $prev = $step - 1; + + $res.="
"; + $res.=$this->reg_nav($step); + $res.=$this->reg_notifica($step); + $res.=" +
+ +
+
+
+
+
+
+
+
+
+
+
"; + if (!$this instanceof BiblioSubscription) + $res.=printNavBar("registration_library"); + else + $res.=printNavBar("subscription_library"); + $res.="
+
+
+
+
"; + if (!$this instanceof BiblioSubscription) + $res.=getConstVar("LIBRARYREG"); + else + $res.=getConstVar("LIBRARYSUB"); + + $res.="
+
+
+"; + $res.=$this->reg_passo($step); + + $res.=" +
+
+
+
+
+
+
+
+
+
+
+
+
+"; + break; + } + + return $res; + } + + public function reg_nav($step) { + $nav = "
"; + + for ($i = 1; $i <= 6; $i++) { + if ($i != 1) { + if ($i <= $step) + $nav.= "
"; + else + $nav.= ""; + } + if ($i <= $step) + $nav.= "
" . $i . "
"; + else + $nav.= "
" . $i . "
"; + } + $nav.= "
"; + return $nav; + } + + public function reg_notifica($step) { + switch ($step) { + case 2: + $ret = "
"; + $ret.=$this->fill_library_identity(); + $ret.="
"; + break; + + case 3: + $ret = "
"; + $ret.=$this->fill_library_identity(); + $ret.=$this->fill_library_identity2(); + $ret.="
"; + + $ret.="
"; + $ret.=$this->fill_library_contacts(); + $ret.="
"; + + break; + + case 4: + $ret = "
"; + $ret.=$this->fill_library_identity(); + $ret.=$this->fill_library_identity2(); + $ret.="
"; + + $ret.="
"; + $ret.=$this->fill_library_contacts(); + $ret.="
"; + + $ret.="
+

" . getConstVar("CATALOGHI") . "

+"; + $ret.=$this->fill_library_cat(); + $ret.="
"; + break; + + case 5: + $ret = "
"; + $ret.=$this->fill_library_identity(); + $ret.=$this->fill_library_identity2(); + $ret.="
"; + + $ret.="
"; + $ret.=$this->fill_library_contacts(); + $ret.="
"; + + $ret.="
+

" . getConstVar("CATALOGHI") . "

+ "; + $ret.=$this->fill_library_cat(); + $ret.="
"; + + $ret.="
+

" . getConstVar("BIBLIO_SERVIZIODD") . "

"; + $ret.=$this->fill_library_service(); + $ret.="
"; + break; + + case 6: + $ret = "
"; + $ret.=$this->fill_library_identity(); + $ret.=$this->fill_library_identity2(); + $ret.="
"; + + $ret.="
"; + $ret.=$this->fill_library_contacts(); + $ret.="
"; + + $ret.="
+

" . getConstVar("CATALOGHI") . "

+ "; + $ret.=$this->fill_library_cat(); + $ret.="
"; + + $ret.="
+

" . getConstVar("BIBLIO_SERVIZIODD") . "

"; + $ret.=$this->fill_library_service(); + $ret.="
"; + if ($this instanceof BiblioSubscription) + { + $ret.="
"; + $ret.=$this->fill_library_subscriptions(); + $ret.="
"; + } + + break; + } + return $ret; + } + + public function reg_passo($step) { + $this->reset_controllo(); + $passo = "
"; + switch ($step) { + case 1: + $passo.="

+
" . getConstVar("BIBLIO_USRPWD") . "
"; + $passo.="
" . getConstVar("BIBLIO_USRPWD_DET") . "
"; + $passo.="

+
"; + $form = new FieldsForm("form_reg_lib"); + $cont_tmp = $form->addField($this->bib["bi_usr"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML("
"); + $cont_tmp = $form->addField($this->bib["bi_pwd"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML("
"); + $cont_tmp = $form->addField($this->bi_pwd_2); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML($this->reg_buttons($step)); + $form->close(); + $passo.=$form->restituisci(); + break; + + case 2: + $passo.="

+ " . getConstVar("BIBLIO_INSER_DATI") . " +
+
+ " . getConstVar("BIBLIO_CORRECT_DATI") . " +

+
"; + + $primo[""] = getConstVar("OPTION_FIRST_LINE"); + $form = new FieldsForm("form_reg_lib"); + $cont_tmp = $form->addField($this->bib["bi_nome"], null, null, ""); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_indi"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_cap"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_citta"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $this->disc_arr = db_elenco("di_id"); + $cont_tmp = $form->addFieldSelect($this->bib["di_id"], null, $this->disc_arr, 0, null, null, "\n"); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML("
"); + $this->nation_arr = db_elenco("na_id"); + $this->nation_arr = $primo + $this->nation_arr; + $cont_tmp = $form->addFieldSelect($this->bib["na_id"], null, $this->nation_arr, 6, "onchange=\"javascript:updateByNation()\"", "", ""); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML("
"); + if ($this->bib["na_id"]->value != "") + $form->addHTML($this->sel_prov($this->bib["na_id"]->value)); + $this->controllo["prov_id"]["obbligo"] = 1; + $form->addHTML("
"); + $disp = "none"; + if ($this->bib["na_id"]->value != "") + $disp = "block"; + $form->addHTML("
"); + if ($this->bib["na_id"]->value != "") + $form->addHTML($this->sel_tipoente($this->bib["na_id"]->value)); + $this->controllo["ti_id"]["obbligo"] = 1; + $form->addHTML("
"); + $disp2 = "none"; + if ($this->tipo_ente != "" && $this->bib["na_id"]->value != "") + $disp2 = "block"; + $form->addHTML("
"); + if ($this->tipo_ente != "" && $this->bib["na_id"]->value != "") + $form->addHTML($this->sel_ente($this->tipo_ente, $this->bib["na_id"]->value)); + $this->controllo["en_id"]["obbligo"] = 1; + $form->addHTML("
"); + $form->addHTML("
" . getConstVar("BIBLIO_PROGETTO") . "
:
"); + + if (get_class($this) != 'Biblio') + $this->prog_arr = db_elenco('pr_id'); + + if ($this->prog_arr != null) { + foreach ($this->prog_arr as $key => $val) { + if (isset($this->progetti[$key])) + $form->addCheckbox("pr_id_" . $key, $key, TRUE, null, null, $val . "
"); + else + $form->addCheckbox("pr_id_" . $key, $key, FALSE, null, null, $val . "
"); + $this->controllo["pr_id_" . $key]["obbligo"] = 0; + } + } + + $form->addHTML("
"); + $cont_tmp=$form->addField($this->bib["bi_piva"],null,null,""); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_cf"], null, null, ""); + $cont_tmp = $form->addField($this->bib["bi_tel"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_fax"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_url"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->close(); + $passo.=$form->restituisci(); + $passo.=$this->reg_buttons($step); + break; + + case 3: + $passo.="

+" . getConstVar("BIBLIO_INSER_DATICATALOGO") . " +
+
"; + $passo .= "

+
+"; + $form = new FieldsForm("form_reg_lib"); + + if ($this->bib["bi_opac"]->value != "") { + $checked = TRUE; + $disabDiv = ""; + $disabForm = ""; + } else { + $checked = FALSE; + $disabDiv = "_disabled"; + $disabForm = "disabled=\"disabled\""; + } + $form->addCheckbox("bi_opac_check", "bi_opac_check", $checked, "onclick=\"javascript:enable_cat('bi_opac')\""); + + $form->addHTML(getConstvar("meta_opac")); + + $form->addHTML("
"); + $cont_tmp = $form->addField($this->bib["bi_opac"], $disabForm); + $this->controllo = array_merge($this->controllo, $cont_tmp); + foreach ($this->DATAcat as $key => $v) + if ($this->DATAcat[$key]["ca_tabella"] == NULL) { + $form->addHTML("
DATAcat[$key]["ca_nome"] . "\">
" . getConstvar($this->DATAcat[$key]["ca_nome"]) . ":
"); + $form->addHTML(" "); + $form->addHTML(getConstVar("NO") . " "); + $form->addRadio($this->DATAcat[$key]["ca_nome"], 0, !$this->DATAcat[$key]["partecipa"], $disabForm); + $form->addHTML(getConstVar("SI") . " "); + $form->addRadio($this->DATAcat[$key]["ca_nome"], 1, $this->DATAcat[$key]["partecipa"], $disabForm); + if ($this->DATAcat[$key]["ca_nome"] == "MAI") + $form->addHTML(" "); + + $form->addHTML(" "); + $form->addHTML("
"); + $cont_tmp[$this->DATAcat[$key]["ca_nome"]]["obbligo"] = 0; + $this->controllo = array_merge($this->controllo, $cont_tmp); + } + $form->addHTML("
+
+"); + foreach ($this->DATAcat as $key => $v) { + $tabella = $this->DATAcat[$key]["ca_tabella"]; + $nome = $this->DATAcat[$key]["ca_nome"]; + $attivo = strtolower($nome) . "_attivo"; + if ($this->DATAcat[$key]["ca_tabella"] != NULL) { + if ($this->DATAcat[$key]["partecipa"]) { + $checked = TRUE; + $disabDiv = ""; + $disabForm = ""; + } else { + $checked = FALSE; + $disabDiv = "_disabled"; + $disabForm = "disabled=\"disabled\""; + } + $form->addCheckbox($nome . "_check", $nome . "_check", $checked, "onclick=\"javascript:enable_cat('" . $nome . "')\""); + $form->addHTML($nome); + $form->addHTML("
"); + foreach ($this->DATAcat[$key]["tabella"] as $key_tab => $v_tab) + if (strpos($this->DATAcat[$key]["tabella"][$key_tab]->fieldname, "_cod")) { + $linkatt = ""; + $extra = ""; + if ($this->DATAcat[$key]["tabella"][$key_tab]->fieldname == strtolower($nome) . "_cod") { + if ($this->DATAcat[$key]["tabella"][$attivo]->value == 1) { + $label = strtolower($nome) . "_label_att"; + $linkatt = ""; + $extra = " onchange=\"javascript:reset_link_label('$label');\""; + } + else + $linkatt = ""; + } + $cont_tmp = $form->addField($this->DATAcat[$key]["tabella"][$key_tab], $disabForm . $extra); + $form->addHTML($linkatt); + $this->controllo = array_merge($this->controllo, $cont_tmp); + } + $form->addHTML("
"); + } + } + $form->addHTML($this->reg_buttons($step)); + $form->close(); + $passo.=$form->restituisci(); + break; + + case 4: + $passo.="

+ " . getConstVar("BIBLIO_INSER_DATISERVIZIO") . " +
+
+ " . getConstVar("BIBLIO_SPEC_MODALITA") . " +

+
"; + $form = new FieldsForm("form_reg_lib"); + $form->addHTML("

" . getConstVar("BIBLIO_SERVIZIODD") . "


"); + $cont_tmp = $form->addField($this->bib["bi_referente_dd"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_email_dd"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_tel_dd"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_costo_ute_dd"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_costo_dd"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $cont_tmp = $form->addField($this->bib["bi_scompenso"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML("
+ +
"); + if ($this->DATAcat[1]["partecipa"] == FALSE) { + $cont_tmp = $form->addField($this->bib["bi_condforni"]); + $this->controllo = array_merge($this->controllo, $cont_tmp); + } else { + $form->addHTML("
+ DATAcat[1]["tabella"]["acnp_cod"]->value . "\" target=\"_blank\">" . getConstVar("BIBLIO_PAGINA_ACNP") . " +
"); + } + $form->addHTML(getConstVar("REG_REGOLAMENTO") . "
"); + $form->close(); + $passo.=$form->restituisci(); + $passo.=$this->reg_buttons($step); + break; + + case 5: + $passo.="

+ " . getConstVar("BIBLIO_ACC_CONDIZIONI") . ""; + $passo.="

+
"; + $year = getConstVar("SUBSCRIPTION_YEAR"); + $tipo_sottoscrizione = getConstVar('LIBRARY'); + $form = new FieldsForm("form_reg_lib"); + $form->addHTML(" +
+ +

" . getConstVar("GEN_COND_NILDE") . "

+
+ + "); + if ($this->isPublicLibrary()) { + $contratto_txt = "contBIBLIO/cond_servizio_biblio" . $year . ".txt"; + } else { + $contratto_txt = "contPRIV/cond_servizio_privata" . $year . ".txt"; + } + $file_contratto = "contents/lang/" . $_SESSION['lang'] . "/contratto/" . $year . "/$contratto_txt"; + $handle = fopen($file_contratto, "r"); + if ($handle) + $contratto = fread($handle, filesize($file_contratto)); + else + $contratto = "Error !"; + fclose($handle); + $form->addTextArea("contratto", $contratto, null, null, "readonly=\"readonly\""); + $form->addHTML("

"); + $form->addRadio("radio_accetta", FALSE, TRUE); + $form->addHTML(getConstVar("NONACCETTO")); + $form->addHTML("
"); + $form->addRadio("radio_accetta", TRUE, FALSE); + $form->addHTML(getConstVar("ACCETTO")); + $cont_tmp["radio_accetta"]["obbligo"] = 1; + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHTML($this->reg_buttons($step)); + $form->close(); + + $passo.=$form->restituisci(); + break; + + case 6: + if ($this->isPublicLibrary()) { + $msg_step6 = getConstVar("BIBLIO_REG_COMPLETE"); + } else { + $msg_step6 = getConstVar("BIBLIO_REG_COMPLETE_PVT"); + } + $passo.="

" . $msg_step6 . "

+
+

+ " . getConstVar("RIEPILOGO_SOTT") . " +
+

"; + break; + } + + $passo.="
+
"; + + return $passo; + } + + public function reg_buttons($step) { + $button = ""; + $button.=getConstVar("REQUIRED_FIELDS"); + if (1 < $step) { + $prev = $step - 1; + $button.= " + \"\" + + " . getConstVar("INDIETRO") . " + + \"\" + "; + } + $next = $step + 1; + $button.= " + \"\" + + " . getConstVar("PROSEGUI") . " + + \"\" + "; + return $button; + } + + public function set_parse($fieldname, $post) { + $flds = new ParserField($post); + $value = $flds->simple_parse($this->bib[$fieldname]); + $this->bib[$fieldname]->value = $value; + } + + public function aggiorna($post) { + $coppie = ""; + $noinsert = array(); + $noinsert["bi_usr"] = TRUE; + if (isset($_SESSION['from3to4']) && $_SESSION['from3to4']) + $noinsert["en_id"] = FALSE; + else + $noinsert["en_id"] = TRUE; + $noinsert["pr_id"] = TRUE; + $noinsert["na_id"] = TRUE; + $noinsert["ti_id"] = TRUE; + if (isset($post['bi_nome'])) + $post['bi_nome'] = ucfirst($post['bi_nome']); + if (isset($post['bi_indi'])) + $post['bi_indi'] = ucfirst(strtolower($post['bi_indi'])); + if (isset($post['bi_citta'])) + $post['bi_citta'] = ucwords(strtolower($post['bi_citta'])); + + $dbfields = new ParserField($post); + if ($post["bi_pwd"] != "" && $post["bi_pwd"] != NULL && $post["bi_pwd"] == $post["bi_pwd_2"]) + $coppie.="bi_pwd=" . $dbfields->parse($this->bib["bi_pwd"]); + else + $noinsert["bi_pwd"] = TRUE; + + foreach ($this->biblio_account_fields as $k => $v) { + $key = $this->biblio_account_fields[$k]->fieldname; + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . $dbfields->parse($this->bib[$key]); + } + } + + if ($coppie != "") { + $query = "UPDATE biblio SET $coppie WHERE bi_id=" . $this->bib["bi_id"]->value; + $result = $_SESSION['db']->execute($query); + if (!$result) + return false; + } + + return true; + } + + public function aggiornaService($post) { + $noinsert = array(); + $noinsert["bi_costo_dd"] = TRUE; + $noinsert["bi_scompenso"] = TRUE; + $coppie = ""; + if (isset($post['bi_referente_dd'])) + $post['bi_referente_dd'] = ucwords(strtolower($post['bi_referente_dd'])); + if (isset($post['bi_referente_ill'])) + $post['bi_referente_ill'] = ucwords(strtolower($post['bi_referente_ill'])); + $dbfields = new ParserField($post); + foreach ($this->biblio_service_fields as $k => $v) { + $key = $this->biblio_service_fields[$k]->fieldname; + $v = $this->biblio_service_fields[$k]->value; + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . $dbfields->parse($this->bib[$key]); + } + } + if ($coppie != "") { + $query = "UPDATE biblio SET $coppie WHERE bi_id=" . $this->bib["bi_id"]->value; + $result = $_SESSION['db']->execute($query); + + if (!$result) + return false; + } + return true; + } + + public function aggiornaCat($post) { + $result = null; + $this->aggiornaObject_cat($post); + if (isset($post["bi_opac"]) && isset($post["bi_opac_check"])) { + $dbfields = new ParserField($post); + $upd_opac = "UPDATE biblio SET bi_opac=" . $dbfields->parse($this->bib["bi_opac"]) . " WHERE bi_id=" . $this->bi_id; + $result = $_SESSION['db']->execute($upd_opac); + } else { + $upd_opac = "UPDATE biblio SET bi_opac='' WHERE bi_id=" . $this->bi_id; + $result = $_SESSION['db']->execute($upd_opac); + $del_mai = "DELETE FROM biblio_catalogo WHERE bi_id=" . $this->bi_id . " AND ca_id=3"; + $result = $_SESSION['db']->execute($del_mai); + } + + $valori_cat = ""; + + foreach ($this->DATAcat as $key_cat => $v_cat) { + if (isset($this->DATAcat[$key_cat]["partecipa"]) && $this->DATAcat[$key_cat]["partecipa"] == TRUE) { + if ($this->DATAcat[$key_cat]["tabella"] != NULL) { + $attributi_tab = ""; + $valori_tab = ""; + $upd = ""; + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + if ($attributi_tab != "") + $attributi_tab.=","; + if ($valori_tab != "") + $valori_tab.=","; + if ($upd != "") + $upd.=","; + + $attributi_tab.=$key_tab; + + if ($key_tab != "bi_id") { + $v = ParserField::quote($v_tab); + $valori_tab.=$v; + $upd.=$key_tab . "=" . $v; + } + } + $query_tab = "INSERT INTO " . $this->DATAcat[$key_cat]["ca_tabella"] . " (" . $attributi_tab . ") VALUES (" . $this->bi_id . "," . $valori_tab . ") ON DUPLICATE KEY UPDATE $upd"; + $result = $_SESSION['db']->execute($query_tab); + } + + if (isset($post[$this->DATAcat[$key_cat]["ca_nome"]])) { + if ($post[$this->DATAcat[$key_cat]["ca_nome"]] == 1) { + $sel = $_SESSION['db']->execute("select bi_id from biblio_catalogo WHERE bi_id=" . $this->bi_id . " AND ca_id=" . $key_cat); + if ($_SESSION['db']->numrows($sel) == 0) { + $valori_cat = "(" . $this->bi_id . "," . $key_cat . ")"; + $query_cat = "INSERT INTO biblio_catalogo (bi_id,ca_id) VALUES " . $valori_cat . ""; + $result = $_SESSION['db']->execute($query_cat); + } + } else { + if (isset($post[$this->DATAcat[$key_cat]["ca_nome"]]) && $post[$this->DATAcat[$key_cat]["ca_nome"]] == 0) { + $queryd_cat = "DELETE FROM biblio_catalogo WHERE bi_id=" . $this->bi_id . " AND ca_id=" . $key_cat; + $result = $_SESSION['db']->execute($queryd_cat); + } + } + } else { + $sel = $_SESSION['db']->execute("select bi_id from biblio_catalogo WHERE bi_id=" . $this->bi_id . " AND ca_id=" . $key_cat); + if ($_SESSION['db']->numrows($sel) == 0) { + $valori_cat = "(" . $this->bi_id . "," . $key_cat . ")"; + $query_cat = "INSERT INTO biblio_catalogo (bi_id,ca_id) VALUES " . $valori_cat . ""; + $result = $_SESSION['db']->execute($query_cat); + } + } + } else { + $queryd_cat = "DELETE FROM biblio_catalogo WHERE bi_id=" . $this->bi_id . " AND ca_id=" . $key_cat; + $result = $_SESSION['db']->execute($queryd_cat); + + if ($this->DATAcat[$key_cat]["ca_tabella"] != "") { + $queryd_cat2 = "DELETE FROM " . $this->DATAcat[$key_cat]["ca_tabella"] . " WHERE bi_id=" . $this->bi_id; + $result2 = $_SESSION['db']->execute($queryd_cat2); + } + } + } + return true; + } + + public function resetCataloghi() { + $catlist = ""; + $resc = $_SESSION['db']->execute("SELECT ca_id FROM gruppo_catalogo WHERE gr_id=1"); + if ($resc && $_SESSION['db']->numrows($resc) > 0) { + while ($c = $_SESSION['db']->fetch($resc)) { + if ($catlist != "") + $catlist.=","; + $catlist.=$c["ca_id"]; + } + if ($catlist != "") + $catlist = "WHERE ca_id IN ($catlist)"; + } + $result_allcat = $_SESSION['db']->execute("SELECT * FROM catalogo $catlist"); + while ($row = $_SESSION['db']->fetch($result_allcat)) { + $key = $row["ca_id"]; + $nome_cat = $row["ca_nome"]; + $tabella_cat = $row["ca_tabella"]; + $url_cat = $row["ca_url"]; + $this->DATAcat[$key]["ca_nome"] = $nome_cat; + $this->DATAcat[$key]["bc_attivo"] = 0; + $this->DATAcat[$key]["partecipa"] = FALSE; + $this->DATAcat[$key]["ca_tabella"] = $tabella_cat; + if ($this->DATAcat[$key]["ca_tabella"] != NULL) + $this->DATAcat[$key]["tabella"] = $_SESSION['db']->fetch_fields($tabella_cat); + else + $this->DATAcat[$key]["tabella"] = NULL; + } + } + + public function aggiornaDB() { + $coppie = ""; + $noinsert = array(); + $noinsert["bi_usr"] = TRUE; + $noinsert["bi_pwd"] = TRUE; + $biblio_fields = array_merge($this->biblio_account_fields, $this->biblio_service_fields); + $noinsert["bi_costo_ute_dd"] = TRUE; + $noinsert["bi_costo_dd"] = TRUE; + $noinsert["bi_scompenso"] = TRUE; + $noinsert["bi_condforni"] = TRUE; + $noinsert["bi_sospini"] = TRUE; + $noinsert["bi_sospfine"] = TRUE; + $noinsert["bi_preavvisososp"] = TRUE; + if ($this->isPublicLibrary()) + $coppie = 'bi_stato=' . getConstVar('BIBLIO_ABI'); + else + $coppie = 'bi_stato=' . getConstVar('BIBLIO_ABI_ATTESAFAX'); + $coppie.=',bi_opac=\'' . addslashes($this->bi_opac) . '\''; + foreach ($biblio_fields as $k => $v) { + $key = $biblio_fields[$k]->fieldname; + $value = $biblio_fields[$k]->value; + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + $coppie.="," . $key . "='" . addslashes($value) . "'"; + } + } + if ($coppie != "") { + $query = "UPDATE biblio SET $coppie WHERE bi_id=" . $this->bib["bi_id"]->value; + $result = $_SESSION['db']->execute($query); + if (!$result) + return false; + } + $valori_insertORupdate_cat = null; + $valori_delete_cat = null; + foreach ($this->DATAcat as $key_cat => $v_cat) { + if ($this->DATAcat[$key_cat]["partecipa"] == TRUE) { + $valori_insertORupdate_cat.="(" . $this->bi_id . "," . $key_cat . "),"; + if ($this->DATAcat[$key_cat]["tabella"] != NULL) { + $attributi_tab_insertORupdate = ""; + $valori_tab_insertORupdate = ""; + $query_update_cat = "bi_id=" . $this->bi_id . ","; + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + $attributi_tab_insertORupdate.=$key_tab . ","; + if ($key_tab != "bi_id") { + $val_tab = ParserField::quote($this->DATAcat[$key_cat]["tabella"][$key_tab]); + $valori_tab_insertORupdate.=$val_tab . ","; + $query_update_cat.=$key_tab . "=" . $val_tab . ","; + } + } + $attributi_tab_insertORupdate = substr($attributi_tab_insertORupdate, 0, -1); + $valori_tab_insertORupdate = substr($valori_tab_insertORupdate, 0, -1); + + $query_update_cat = substr($query_update_cat, 0, -1); + $query_tab = "INSERT INTO " . $this->DATAcat[$key_cat]["ca_tabella"] . " (" . $attributi_tab_insertORupdate . ") VALUES (" . $this->bi_id . "," . $valori_tab_insertORupdate . ") ON DUPLICATE KEY UPDATE $query_update_cat"; + $result_tab = $_SESSION['db']->execute($query_tab); + } + } else { + $valori_delete_cat.="(bi_id=" . $this->bi_id . " AND ca_id=" . $key_cat . ") OR "; + if ($this->DATAcat[$key_cat]["tabella"] != NULL) { + $query_DELETE_cat = "DELETE FROM " . $this->DATAcat[$key_cat]["ca_tabella"] . " WHERE bi_id=" . $this->bi_id; + $result_del_cat = $_SESSION['db']->execute($query_DELETE_cat); + } + } + } + if ($this->DATAcat[3]["partecipa"] == 1) { + $query_cat_MAI = "INSERT INTO biblio_catalogo (bi_id,ca_id) VALUES (" . $this->bi_id . ",3) ON DUPLICATE KEY UPDATE bi_id=bi_id, ca_id=ca_id"; + } else { + $query_cat_MAI = "DELETE FROM biblio_catalogo WHERE bi_id=" . $this->bi_id . " AND ca_id=3"; + } + $result_cat_MAI = $_SESSION['db']->execute($query_cat_MAI); + if ($valori_insertORupdate_cat != null) { + $valori_insertORupdate_cat = substr($valori_insertORupdate_cat, 0, -1); + $query_cat = "INSERT INTO biblio_catalogo (bi_id,ca_id) VALUES " . $valori_insertORupdate_cat . " ON DUPLICATE KEY UPDATE bi_id=bi_id, ca_id=ca_id"; + $result_cat = $_SESSION['db']->execute($query_cat); + } + if ($valori_delete_cat != null) { + $valori_delete_cat = substr($valori_delete_cat, 0, -3); + $query_cat = "DELETE FROM biblio_catalogo WHERE $valori_delete_cat"; + $result_cat = $_SESSION['db']->execute($query_cat); + } + $coppie_pr = ''; + foreach ($this->progetti as $pr_id => $pr_name) { + $coppie_pr.="(" . $this->bi_id . ",$pr_id),"; + } + $coppie_pr = substr($coppie_pr, 0, -1); + $query_DELETE_prog = "DELETE FROM biblio_progetto WHERE bi_id=" . $this->bi_id; + $result_pr_delete = $_SESSION['db']->execute($query_DELETE_prog); + if (sizeof($this->progetti) != 0) { + $query_INSERT_prog = "INSERT INTO biblio_progetto (bi_id,pr_id) VALUES $coppie_pr"; + $result_pr_insert = $_SESSION['db']->execute($query_INSERT_prog); + } + return $this->bib["bi_id"]->value; + } + + public function aggiornaObject($post) { + foreach ($this->controllo as $key => $v) { + if (isset($this->bib[$key])) { + $this->bib[$key]->value = isset($post[$key]) ? $post[$key] : null; + } + } + if ($this instanceof BiblioSubscription) { + if (isset($post['anno_fatt'])) + $this->anno_fatt = $post['anno_fatt']; + if (isset($post['fatt_referente'])) + $this->fatt_referente = $post['fatt_referente']; + if (isset($post['fatt_referente_mail'])) + $this->fatt_referente_mail = $post['fatt_referente_mail']; + if (isset($post['fatt_referente_tel'])) + $this->fatt_referente_tel = $post['fatt_referente_tel']; + if (isset($post['fatt_altrenote'])) + $this->fatt_altrenote = $post['fatt_altrenote']; + if (isset($post['fatt_data_ordine_gg']) && isset($post['fatt_data_ordine_mm']) && isset($post['fatt_data_ordine_aaaa'])) + $this->fatt_data_ordine=build_date($post['fatt_data_ordine_aaaa'], $post['fatt_data_ordine_mm'], $post['fatt_data_ordine_gg']); + if (isset($post['fatt_cig'])) + $this->fatt_cig=$post['fatt_cig']; + if (isset($post['fatt_cartacea'])) + $this->fatt_cartacea=$post['fatt_cartacea']; + + } + + return TRUE; + } + + public function aggiornaObject_cat($post) { + foreach ($this->DATAcat as $key => $v) { + if ($this->DATAcat[$key]["ca_tabella"] == NULL) { + $this->DATAcat[$key]["partecipa"] = isset($post[$this->DATAcat[$key]["ca_nome"]]) ? $post[$this->DATAcat[$key]["ca_nome"]] : null; + } else { + if (isset($post[$this->DATAcat[$key]["ca_nome"] . "_check"])) { + $this->DATAcat[$key]["partecipa"] = TRUE; + foreach ($this->DATAcat[$key]["tabella"] as $campo => $v_2) { + if (isset($post[$campo])) + $this->DATAcat[$key]["tabella"][$campo]->value = $post[$campo]; + } + } + else { + $this->DATAcat[$key]["partecipa"] = FALSE; + } + } + } + return TRUE; + } + + public function aggiornaObject_progetti($post) { + $this->tipo_ente = isset($post["ti_id"]) ? $post["ti_id"] : null; + $this->progetti = array(); + foreach ($this->controllo as $key => $v) { + if ((strpos($key, "pr_id_") !== FALSE) && isset($post[$key])) { + $this->progetti[$post[$key]] = $this->prog_arr[$post[$key]]; + } + } + return TRUE; + } + + public function sel_ente($idtipoen,$naz=null) { + $form= new FieldsForm(); + + $primo[""] = getConstVar("OPTION_FIRST_LINE"); + $wh="ti_id=".$idtipoen; + if($naz!="") $wh.=" AND na_id='$naz' AND en_id<>".getConstVar("ID_AUTHORG"); + $this->en_arr=db_elenco("en_id",$wh); + if ($this->en_arr) + $this->en_arr = $primo + $this->en_arr; + if (isset($_SESSION['from3to4']) && $_SESSION['from3to4']) { + $options = "\n"; + } + else + $options="\n"; + + $cont_tmp = $form->addFieldSelect($this->bib["en_id"], null, $this->en_arr, 1, null, null, $options); + if ($this->controllo) + $this->controllo = array_merge($this->controllo, $cont_tmp); + else + $this->controllo = $cont_tmp; + + return $form->restituisci(); + } + + public function sel_tipoente($naid) { + $form = new FieldsForm(); + $primo[""] = getConstVar("OPTION_FIRST_LINE"); + $this->en_arr = db_elenco("ti_id", "na_id='$naid'"); + $this->en_arr = $primo + $this->en_arr; + $form->addHTML("
" . getConstVar("ti_id") . ":
"); + if (isset($_SESSION['from3to4']) && $_SESSION['from3to4']) { + $options = "" . getConstVar("CAMPO_OBBLIGATORIO") . ""; + } + else + $options = "".getConstVar("CAMPO_OBBLIGATORIO").""; + $cont_tmp = $form->addSelect("ti_id", null, $this->en_arr, $this->tipo_ente, null, "onchange=\"javascript:updateInst()\"", "", $options); + $form->addHTML("
"); + return $form->restituisci(); + } + + public function sel_prov($idnation) { + $form = new FieldsForm(); + $primo[""] = getConstVar("OPTION_FIRST_LINE"); + $this->prov_arr = db_elenco("prov_id", "na_id='" . $idnation . "'"); + $this->prov_arr = array_merge($primo, $this->prov_arr); + $cont_tmp = $form->addFieldSelect($this->bib["prov_id"], null, $this->prov_arr, 1, null, null); + $this->controllo = array_merge($this->controllo, $cont_tmp); + return $form->restituisci(); + } + + public function inserisciDB() { + if ($this->isPublicLibrary()) + $this->bib['bi_stato']->value = getConstVar('BIBLIO_NUOVA'); + else + $this->bib['bi_stato']->value = getConstVar('BIBLIO_NUOVA_ATTESA_FAX'); + $attributi_bib = ""; + $valori_bib = ""; + foreach ($this->bib as $key => $v) + if ($key != "bi_id") { + if ($attributi_bib != "") + $attributi_bib.=","; + if ($valori_bib != "") + $valori_bib.=","; + + $attributi_bib.=$key; + $valori_bib.=ParserField::quote($this->bib[$key]); + } + + if ($attributi_bib != "") { + $query = "INSERT INTO biblio ($attributi_bib) VALUES ($valori_bib)"; + $result = $_SESSION['db']->execute($query); + $idbib = $_SESSION['db']->last_id(); + if ($result) { + $_SESSION['db']->execute("INSERT INTO biblio_gruppo (bi_id, gr_id) VALUES (" . $idbib . ",1)"); + if ($this->progetti != NULL) { + $valori_prog = ""; + foreach ($this->progetti as $key => $value) { + if ($valori_prog != "") + $valori_prog.=","; + $valori_prog.="(" . $idbib . "," . $key . ")"; + } + $_SESSION['db']->execute("INSERT INTO biblio_progetto (bi_id, pr_id) VALUES $valori_prog"); + } + $valori_cat = ""; + foreach ($this->DATAcat as $key_cat => $v_cat) { + if ($this->DATAcat[$key_cat]["partecipa"] == TRUE) { + if ($valori_cat != "") + $valori_cat.=","; + $valori_cat.="(" . $idbib . "," . $key_cat . ")"; + if ($this->DATAcat[$key_cat]["tabella"] != NULL) { + $attributi_tab = ""; + $valori_tab = ""; + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + if ($attributi_tab != "") + $attributi_tab.=","; + if ($valori_tab != "") + $valori_tab.=","; + $attributi_tab.=$key_tab; + if ($key_tab != "bi_id") + $valori_tab.=ParserField::quote($this->DATAcat[$key_cat]["tabella"][$key_tab]); + } + $query_tab = "INSERT INTO " . $this->DATAcat[$key_cat]["ca_tabella"] . " (" . $attributi_tab . ") VALUES (" . $idbib . "," . $valori_tab . ")"; + $result_tab = $_SESSION['db']->execute($query_tab); + } + } + } + if ($valori_cat != "") { + $query_cat = "INSERT INTO biblio_catalogo (bi_id,ca_id) VALUES " . $valori_cat . ""; + $result_cat = $_SESSION['db']->execute($query_cat); + } + return $idbib; + } + else return FALSE; + } + else return FALSE; + } + + function inserisciStoricoSottoscrizioni($id_bib) { + if ($this instanceof BiblioSubscription) { + $_importo = $this->importo; + $_pagato = 0; + $_opzione_data_fattura = $this->anno_fatt; + if (!$this->bi_notefatt) + $_intestazione_fattura = addslashes($this->bi_nome . ",\n" . $this->bi_indi . " - " . $this->bi_citta . " (" . $this->prov_id . ")\n" . $this->bi_cap . " - " . $this->na_id . "\nP.IVA: " . $this->bi_piva . "\nCF: " . $this->bi_cf); + else { + $_intestazione_fattura = addslashes($this->bi_notefatt); + } + $_nuova_biblio = 0; + } else { + $_importo = 0.00; + $_pagato = 1; + $_opzione_data_fattura = 'null'; + $_intestazione_fattura = 'null'; + $_nuova_biblio = 1; + } + $_anno = getConstVar('SUBSCRIPTION_YEAR'); + $_condforni = isset($this->bi_condforni) ? addslashes($this->bi_condforni) : 'null'; + $_scompenso = isset($this->bi_scompenso) ? $this->bi_scompenso : 'null'; + $_costo_dd = isset($this->bi_costo_dd) ? $this->bi_costo_dd : 'null'; + $_costo_ill = isset($this->bi_costo_ill) ? $this->bi_costo_ill : 'null'; + $tipo_sottoscrizione = $this->kindOfContractLibrary($_anno); + if ($this instanceof BiblioSubscription) + $this->tipo_sottoscrizione = $tipo_sottoscrizione; + switch ($tipo_sottoscrizione) { + case getConstVar('ADERENTE'): + if ($this instanceof BiblioSubscription) { + $_tipo_contratto = 2; + $_nome_contratto = "cond_servizio_aderente"; + } else { + if ($this->isPublicLibrary()) { + $_tipo_contratto = 1; + $_nome_contratto = "cond_servizio_biblio"; + } else { + $_tipo_contratto = 0; + $_nome_contratto = "cond_servizio_privata"; + } + } + break; + case getConstVar('SINGOLA_PUB'): + $_tipo_contratto = 1; + $_nome_contratto = "cond_servizio_biblio"; + break; + case getConstVar('SINGOLA_PVT'): + $_tipo_contratto = 0; + $_nome_contratto = "cond_servizio_privata"; + break; + case getConstVar('ADERENTE_ANNO_PRECEDENTE'): + if ($this->isPublicLibrary()) { + $_tipo_contratto = 1; + $_nome_contratto = "cond_servizio_biblio"; + } else { + $_tipo_contratto = 0; + $_nome_contratto = "cond_servizio_privata"; + } + break; + } + $fatt_referente=""; + $fatt_referente_mail=""; + $fatt_referente_tel=""; + $fatt_altrenote=""; + $fatt_data_ordine=""; + $fatt_cig=""; + $fatt_cartacea=0; + if($this instanceof BiblioSubscription) + { + $this->tipo_sottoscrizione=$tipo_sottoscrizione; + + $fatt_referente=SQL_escape($this->fatt_referente); + $fatt_referente_mail=$this->fatt_referente_mail; + $fatt_referente_tel=$this->fatt_referente_tel; + $fatt_altrenote=SQL_escape($this->fatt_altrenote); + $fatt_data_ordine= $this->fatt_data_ordine; + $fatt_cig=$this->fatt_cig; + $fatt_cartacea=$this->fatt_cartacea; + } + $_nome_contratto=$id_bib."-".$_nome_contratto.$_anno; + $this->nomecontratto=$_nome_contratto; + $query = "INSERT INTO storico_sottoscrizioni (bi_id,bi_en,st_pagato,st_importo,st_intestazione_fattura,st_data_opzione_fattura,st_anno_contratto,st_tipo_contratto,st_nome_contratto,st_nuova_biblio,bi_condforni,bi_scompenso,bi_costo_dd,bi_costo_ill,st_fatt_referente,st_fatt_referente_mail,st_fatt_referente_tel,st_fatt_altrenote, st_fatt_data_ordine,st_fatt_cig,st_fatt_cartacea) VALUES + ($id_bib,".$this->en_id.",$_pagato,$_importo,'$_intestazione_fattura',$_opzione_data_fattura,$_anno,$_tipo_contratto,'$_nome_contratto',$_nuova_biblio,'$_condforni','$_scompenso','$_costo_dd','$_costo_ill','$fatt_referente','$fatt_referente_mail','$fatt_referente_tel','$fatt_altrenote','$fatt_data_ordine','$fatt_cig','$fatt_cartacea')"; + $_SESSION['db']->execute($query); + } + + function modifica($action = "action_biblio.php") { + $this->bib["bi_pwd"]->value = ""; + $this->bi_pwd_2->value = ""; + $this->bib["bi_pwd"]->isnull = TRUE; + $this->bi_pwd_2->isnull = TRUE; + $this->form($action, FALSE); + } + + function form($action) { + $this->reset_controllo(); + $form = new FieldsForm("form_library", "javascript:modificaBiblioAccount('$action')"); + $form->addHidden("bi_id", $this->bib["bi_id"]->value, null, "\n"); + $form->addHidden("op", "update", null, "\n"); + $form->addHTML("
"); + $this->edit_library_identity($form); + $form->addHTML("
"); + $form->addHTML("
"); + $this->edit_library_contacts($form); + $form->addButton("save_btn", getConstVar("SAVE"), "class=\"submit\" onclick=\"javascript:salvaBiblioAccount()\""); + if (isset($_SESSION['from3to4']) && !$_SESSION['from3to4']) { + $form->addHTML("  "); + $form->addButton("cancel_btn", getConstVar("CANCEL"), "class=\"submit\" onclick=\"javascript:undoModificaBiblio()\""); + } + $form->addHTML(getConstVar("REQUIRED_FIELDS")); + $form->addHTML("
"); + $code_controllo = urlencode(serialize($this->controllo)); + $form->addHidden("controllo", $code_controllo); + $form->close(); + $form->stampa(); + } + + function formService() { + $this->reset_controllo(); + + $form = new FieldsForm("form_library_serv", "javascript:modificaService('action_biblio.php')"); + $form->addHidden("bi_id", $this->bib["bi_id"]->value, null, "\n"); + $form->addHidden("op", "updateServ", null, "\n"); + $form->addHTML("
"); + $this->edit_library_service($form); + $form->addHTML("
"); + $form->addHTML("
"); + $this->edit_library_suspension($form); + $form->addHTML("
"); + $form->addButton("save_btn", getConstVar("SAVE"), "class=\"submit\" onclick=\"javascript:salvaService()\""); + if (isset($_SESSION['from3to4']) && !$_SESSION['from3to4']) { + $form->addHTML("  "); + $form->addButton("cancel_btn", getConstVar("CANCEL"), "class=\"submit\" onclick=\"javascript:undoModificaService()\""); + } + $form->addHTML(getConstVar("REQUIRED_FIELDS")); + $form->addHTML("
"); + $code_controllo = urlencode(serialize($this->controllo)); + $form->addHidden("controllo", $code_controllo); + $form->close(); + $form->stampa(); + } + + public function edit_library_identity($form) { + $form->addHTML(FieldRender::renderField($this->bib["bi_usr"])); + $p = $form->addField($this->bib["bi_pwd"]); + $this->controllo = array_merge($this->controllo, $p); + $p2 = $form->addField($this->bi_pwd_2); + $this->controllo = array_merge($this->controllo, $p2); + $nome = $form->addField($this->bib["bi_nome"]); + $this->controllo = array_merge($this->controllo, $nome); + $primo[""] = getConstVar("OPTION_FIRST_LINE"); + $this->disc_arr = db_elenco("di_id"); + $this->disc_arr = $primo + $this->disc_arr; + $disc = $form->addFieldSelect($this->bib["di_id"], null, $this->disc_arr, 0, null, null, "\n"); + $this->controllo = array_merge($this->controllo, $disc); + if (isset($_SESSION['from3to4']) && $_SESSION['from3to4']) { + $form->addHTML("
"); + if ($this->bib["na_id"]->value != "") + $form->addHTML($this->sel_tipoente($this->bib["na_id"]->value)); + $this->controllo["ti_id"]["obbligo"] = 1; + $form->addHTML("
"); + $form->addHTML("
"); + if ($this->tipo_ente != "" && $this->bib["na_id"]->value !="") $form->addHTML($this->sel_ente($this->tipo_ente,$this->bib["na_id"]->value)); + $this->controllo["en_id"]["obbligo"] = 1; + $form->addHTML("
"); + } else + $form->addHTML(FieldRender::render("en_id",$this->en_arr[$this->bib["en_id"]->value])); + + foreach ($this->progetti as $key=>$value) { + $form->addHTML(FieldRender::render("pr_id",$this->progetti[$key])); + } + + } + + public function edit_library_contacts($form) { + $ind = $form->addField($this->bib["bi_indi"]); + $this->controllo = array_merge($this->controllo, $ind); + $cap = $form->addField($this->bib["bi_cap"]); + $this->controllo = array_merge($this->controllo, $cap); + $form->addField($this->bib["bi_citta"]); + $form->addHTML(FieldRender::render("na_id", $this->nation_arr[$this->bib["na_id"]->value])); + $form->addHTML("
"); + if ($this->bib["na_id"]->value != "") $form->addHTML($this->sel_prov($this->bib["na_id"]->value)); + $this->controllo["prov_id"]["obbligo"] = 1; + $form->addHTML("
"); + + $piva = $form->addField($this->bib["bi_piva"]); + $this->controllo = array_merge($this->controllo, $piva); + $cf = $form->addField($this->bib["bi_cf"]); + $this->controllo = array_merge($this->controllo, $cf); + $tel = $form->addField($this->bib["bi_tel"]); + $this->controllo = array_merge($this->controllo, $tel); + $fax = $form->addField($this->bib["bi_fax"]); + $this->controllo = array_merge($this->controllo, $fax); + $url = $form->addField($this->bib["bi_url"]); + $this->controllo = array_merge($this->controllo, $url); + } + + public function edit_library_service($form) { + $ref = $form->addField($this->bib["bi_referente_dd"]); + $this->controllo = array_merge($this->controllo, $ref); + $email = $form->addField($this->bib["bi_email_dd"]); + $this->controllo = array_merge($this->controllo, $email); + $tel = $form->addField($this->bib["bi_tel_dd"]); + $this->controllo = array_merge($this->controllo, $tel); + } + + public function edit_library_conditions($form) { + $form->addHTML("

" . getConstVar("LABEL_BIB_SERVIZIOUTENTI") . "

"); + $costoute = $form->addField($this->bib["bi_costo_ute_dd"]); + $this->controllo = array_merge($this->controllo, $costoute); + $form->addHTML("

" . getConstVar("LABEL_BIB_SERVIZIOBIBLIO") . "

"); + $form->addHTML(FieldRender::renderField($this->bib["bi_costo_dd"])); + if (isset($_SESSION['from3to4']) && $_SESSION['from3to4']) { + if ($this->bib["bi_costo_dd"]->value != 0) { + $scompenso = $form->addField($this->bib["bi_scompenso"]); + $this->controllo = array_merge($this->controllo, $scompenso); + } + else + $form->addHTML(FieldRender::renderField($this->bib["bi_scompenso"])); + } else { + $form->addHTML(FieldRender::renderField($this->bib["bi_scompenso"])); + } + + + if ($this->DATAcat[1]["partecipa"] == FALSE) { + $cond = $form->addField($this->bib["bi_condforni"]); + $this->controllo = array_merge($this->controllo, $cond); + } + else + $form->addHTML("
+" . getConstVar("LABEL_CONDFORNI_ACNP") . "DATAcat[1]["tabella"]["acnp_cod"]->value . "&language=ITALIANO\" target=\"_blank\">ACNP +
+"); + } + + public function edit_library_suspension($form) { + $form->addHTML("
" . getConstVar("LABEL_SOSP_SERVIZIO") . "
"); + $form->addHTML(getConstVar("DAL").": "); + $sospini = $form->addField($this->bib["bi_sospini"]); + $this->controllo = array_merge($this->controllo, $sospini); + $form->addHTML("   ".getConstVar("AL_TIME").": "); + $sospfine = $form->addField($this->bib["bi_sospfine"]); + $this->controllo = array_merge($this->controllo, $sospfine); + $form->addHTML(getConstVar("GIORNI_PREAVVISO_SOSPENSIONE")); + $form->addField($this->bib["bi_preavvisososp"]); + } + + public function edit_library_cat($form) { + if ($this->bib["bi_opac"]->value != "") { + $checked = TRUE; + $disabDiv = ""; + $disabForm = ""; + } else { + $checked = FALSE; + $disabDiv = "_disabled"; + $disabForm = "disabled=\"disabled\""; + } + $form->addCheckbox("bi_opac_check", "bi_opac_check", $checked, "onclick=\"javascript:enable_cat('bi_opac')\""); + $form->addHTML(getConstvar("meta_opac")); + $form->addHTML("
"); + + $opac = $form->addField($this->bib["bi_opac"], $disabForm, null, null, null, 1); + $this->controllo = array_merge($this->controllo, $opac); + foreach ($this->DATAcat as $key => $v) { + if ($this->DATAcat[$key]["ca_tabella"] == NULL) { + $form->addHTML("
DATAcat[$key]["ca_nome"] . "\">
" . getConstvar($this->DATAcat[$key]["ca_nome"]) . ":
"); + $form->addHTML(getConstVar("NO") . " "); + $form->addRadio($this->DATAcat[$key]["ca_nome"], 0, !$this->DATAcat[$key]["partecipa"], $disabForm); + $form->addHTML(getConstVar("SI") . " "); + $form->addRadio($this->DATAcat[$key]["ca_nome"], 1, $this->DATAcat[$key]["partecipa"], $disabForm); + $form->addHTML("
"); + if ($this->DATAcat[$key]["ca_nome"] == "MAI") + $form->addHTML(" "); + $cont_tmp[$this->DATAcat[$key]["ca_nome"]]["obbligo"] = 0; + $this->controllo = array_merge($this->controllo, $cont_tmp); + } + } + $form->addHTML("
"); + foreach ($this->DATAcat as $key => $v) { + if ($this->DATAcat[$key]["ca_tabella"] != NULL) { + $tabella = $this->DATAcat[$key]["ca_tabella"]; + $nome = $this->DATAcat[$key]["ca_nome"]; + $attivo = strtolower($nome) . "_attivo"; + $checked = FALSE; + $disabDiv = "_disabled"; + $disabForm = "disabled=\"disabled\""; + if ($this->DATAcat[$key]["partecipa"] == TRUE) { + $first = false; + $form->addHTML($nome); + $form->addHTML("
"); + $cat_attivo = strtolower($this->DATAcat[$key]["ca_nome"]) . "_attivo"; + foreach ($this->DATAcat[$key]["tabella"] as $key_tab => $v_tab) { + if (strpos($this->DATAcat[$key]["tabella"][$key_tab]->fieldname, "_cod")) { + if ($this->DATAcat[$key]["tabella"][$attivo]->value == 1) { + $extra = ""; + $first = FALSE; + } + else + $extra = ""; + $form->addCheckbox($nome . "_check", $nome . "_check", TRUE, "style=\"display:none\""); + $form->addHTML(FieldRender::renderField($this->DATAcat[$key]["tabella"][$key_tab], null, $extra)); + } + } + $form->addHTML("
"); + } + else { + if ($this->DATAcat[$key]["bc_attivo"] == 1) { + $checked = TRUE; + $disabDiv = ""; + $disabForm = ""; + } else { + $checked = FALSE; + $disabDiv = "_disabled"; + $disabForm = "disabled=\"disabled\""; + } + $form->addCheckbox($nome . "_check", $nome . "_check", $checked, "onclick=\"javascript:enable_cat('" . $nome . "')\""); + $form->addHTML($nome); + $form->addHTML("
"); + foreach ($this->DATAcat[$key]["tabella"] as $key_tab => $v_tab) + if (strpos($this->DATAcat[$key]["tabella"][$key_tab]->fieldname, "_cod")) { + $cont_tmp = $form->addField($this->DATAcat[$key]["tabella"][$key_tab], $disabForm); + $this->controllo = array_merge($this->controllo, $cont_tmp); + } + $form->addHTML("
"); + } + } + } + } + + function formCat() { + $this->reset_controllo(); + $form = new FieldsForm("cat_data_form", "javascript:modificaCataloghi('action_biblio.php')"); + $form->addHidden("bi_id", $this->bib["bi_id"]->value, null, "\n"); + $form->addHidden("op", "updateCat", null, "\n"); + $form->addHTML("
"); + $this->edit_library_cat($form); + $form->addHTML("
"); + $form->addHTML("
"); + $form->addButton("save_btn", getConstVar("SAVE"), "class=\"submit\" onclick=\"javascript:salvaCataloghi()\""); + if (isset($_SESSION['from3to4']) && !$_SESSION['from3to4']) { + $form->addHTML("  "); + $form->addButton("cancel_btn", getConstVar("CANCEL"), "class=\"submit\" onclick=\"javascript:undoModificaCataloghi()\""); + } + $form->addHTML(getConstVar("REQUIRED_FIELDS")); + $code_controllo = urlencode(serialize($this->controllo)); + $form->addHidden("controllo", $code_controllo); + + $form->close(); + $form->stampa(); + } + + public function fill_library_identity() { + $ret = FieldRender::renderField($this->bib["bi_usr"]); + $ret.="
+" . getConstVar("bi_pwd") . ": " . getConstVar("CHOOSED_PWD") . " + +
"; + return $ret; + } + + public function fill_library_identity2() { + $ret = FieldRender::renderField($this->bib["bi_nome"]); + $ret.=FieldRender::render("di_id", $this->disc_arr[$this->bib["di_id"]->value]); + $ret.=FieldRender::render("en_id", $this->en_arr[$this->bib["en_id"]->value]); + foreach ($this->progetti as $key => $value) { + $ret.=FieldRender::render("pr_id", $this->progetti[$key]); + } + return $ret; + } + + public function fill_library_contacts() { + $ret = FieldRender::renderField($this->bib["bi_indi"]); + $ret.=FieldRender::renderField($this->bib["bi_cap"]); + $ret.=FieldRender::renderField($this->bib["bi_citta"]); + $ret.=FieldRender::render("na_id", $this->nation_arr[$this->bib["na_id"]->value]); + $ret.=FieldRender::render("prov_id", $this->prov_arr[$this->bib["prov_id"]->value]); + $ret.=FieldRender::renderField($this->bib["bi_piva"]); + $ret.=FieldRender::renderField($this->bib["bi_cf"]); + $ret.=FieldRender::renderField($this->bib["bi_tel"]); + $ret.=FieldRender::renderField($this->bib["bi_fax"]); + $ret.=FieldRender::renderField($this->bib["bi_url"]); + return $ret; + } + + public function fill_library_cat() { + $ret = FieldRender::renderField($this->bib["bi_opac"]); + foreach ($this->DATAcat as $key_cat => $v_cat) + if ($this->DATAcat[$key_cat]["partecipa"] == TRUE && $this->DATAcat[$key_cat]["tabella"] == NULL) { + if ($this->DATAcat[$key_cat]["bc_attivo"] == 1) + $extra = ""; + else + $extra = ""; + $ret.=FieldRender::render($this->DATAcat[$key_cat]["ca_nome"], getConstVar("SI"), $extra); + } + foreach ($this->DATAcat as $key_cat => $v_cat) { + if ($this->DATAcat[$key_cat]["partecipa"] == TRUE && $this->DATAcat[$key_cat]["tabella"] != NULL) { + $first = TRUE; + + $cat_attivo = strtolower($this->DATAcat[$key_cat]["ca_nome"]) . "_attivo"; + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + + if (strpos($this->DATAcat[$key_cat]["tabella"][$key_tab]->fieldname, "_cod")) { + if ($this->DATAcat[$key_cat]["tabella"][$cat_attivo]->value == 1 && $first) { + $extra = ""; + $first = FALSE; + } + else + $extra = ""; + + $ret.=FieldRender::renderField($this->DATAcat[$key_cat]["tabella"][$key_tab], null, $extra); + } + } + } + } + return $ret; + } + + public function fill_library_service() { + $ret = FieldRender::renderField($this->bib["bi_referente_dd"]); + $ret.=FieldRender::renderField($this->bib["bi_email_dd"]); + $ret.=FieldRender::renderField($this->bib["bi_tel_dd"]); + return $ret; + } + + public function fill_library_conditions() { + $ret = "

" . getConstVar("LABEL_BIB_SERVIZIOUTENTI") . "

"; + $ret.=FieldRender::renderField($this->bib["bi_costo_ute_dd"]); + if ($this->bib["bi_id"]->value) { + $ret.="
"; + $ret.=" " . getConstVar("URL_REGISTRAZIONE_UTENTI") . ": value . "\" target=\"_blank\">" . getConstVar("HTTPROOTDIR") . "/register_ute.php?idbib=" . $this->bib["bi_id"]->value . ""; + $ret.="
"; + } + $ret.="

" . getConstVar("LABEL_BIB_SERVIZIOBIBLIO") . "

"; + $ret.=FieldRender::renderField($this->bib["bi_costo_dd"]); + $ret.=FieldRender::renderField($this->bib["bi_scompenso"]); + if ($this->DATAcat[1]["partecipa"] == FALSE) + $ret.=FieldRender::renderField($this->bib["bi_condforni"]); + else + $ret.="
+" . getConstVar("LABEL_CONDFORNI_ACNP") . " DATAcat[1]["tabella"]["acnp_cod"]->value . "\" target=\"_blank\">ACNP +
+"; + return $ret; + } + + public function fill_suspension() { + $res = "
" . getConstVar("LABEL_SOSP_SERVIZIO") . "
"; + if ($this->bib["bi_sospini"]->value != NULL) { + $res.=getConstVar("LABEL_SOSP_SERVIZIO_DATA"); + $res.=FieldRender::renderField($this->bib["bi_sospini"]); + $res.=" έως "; + $res.=FieldRender::renderField($this->bib["bi_sospfine"]); + if ($this->bib["bi_preavvisososp"]->value != 0) + $res.="
" . getConstVar("GIORNI_PREAVVISO_SOSPENSIONE") . "; " . $this->bib["bi_preavvisososp"]->value; + } + else + $res.=getConstVar("LABEL_NO_SOSPENSIONE"); + + return $res; + } + + function visualizza($action = "action_library.php") { + $form = new FieldsForm("form_library", ""); + $form->addHidden("bi_id", $this->bib["bi_id"]->value); + $form->addHidden("op", "edit"); + $form->addHTML("" . getConstVar("EDIT_ACCOUNT") . ""); + $form->addHTML($this->visualizza_identity()); + $form->addHTML($this->visualizza_contacts()); + $form->close(); + return $form->restituisci(); + } + + function visualizza_popup() { + $indi = $this->bi_indi != null ? "
" . $this->bi_indi . " " : null; + $citta = $this->bi_citta != null ? " " . $this->bi_citta . " " : null; + $prov = $this->prov_id != null ? "(" . $this->prov_id . ")" : null; + $cap = $this->bi_cap != null ? " - " . $this->bi_cap : null; + $tel = $this->bi_tel != null ? "
" . getConstVar("bi_tel") . ": " . $this->bi_tel : null; + $fax = $this->bi_fax != null ? "
" . getConstVar("bi_fax") . ": " . $this->bi_fax : null; + $piva = $this->bi_piva != null ? "
" . getConstVar("bi_piva") . ": " . $this->bi_piva : null; + $url = $this->bi_url != null ? "
" . getConstVar("bi_url") . ": " . $this->bi_url : null; + $referente = null; + if ($this->bi_referente_dd != null) { + $referente = "

" . getConstVar("bi_referente_dd") . "
" . $this->bi_referente_dd . "
" . $this->bi_email_dd . "
" . $this->bi_tel_dd; + } + $cataloghi = ""; + foreach ($this->DATAcat as $key_cat => $v_cat) { + if ($this->DATAcat[$key_cat]["partecipa"] == TRUE && $this->DATAcat[$key_cat]["tabella"] != NULL) { + + $cat_attivo = strtolower($this->DATAcat[$key_cat]["ca_nome"]) . "_attivo"; + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + if (strpos($this->DATAcat[$key_cat]["tabella"][$key_tab]->fieldname, "_cod")) { + if ($this->DATAcat[$key_cat]["tabella"][$cat_attivo]->value == 1) { + $extra = ""; + } + else + $extra = ""; + $cataloghi.=FieldRender::renderField($this->DATAcat[$key_cat]["tabella"][$key_tab], null, $extra . "
"); + } + } + if ($key_cat == 1) { + $cod = $this->DATAcat[1]["tabella"]["acnp_cod"]->value; + $cataloghi.="" . getConstVar("BIBLIO_PAGINA_ACNP") . ""; + } + } + } + + if ($cataloghi != "") + $cataloghi = "
" . getConstVar("CATALOGHI") . ":" . $cataloghi . "
"; + + return "" . $this->bi_nome . "" . $indi . $cap . $citta . $prov . $tel . $fax . $piva . $cf . $url . $referente . $cataloghi; + } + + public function visualizza_identity() { + $res = "
"; + $res.=$this->fill_library_identity(); + $res.=$this->fill_library_identity2(); + $res.="
"; + return $res; + } + + public function visualizza_contacts() { + $res = "
"; + $res.=$this->fill_library_contacts(); + $res.="
"; + return $res; + } + + public function visualizza_cat() { + $form = new FieldsForm("cat_data_form"); + $form->addHidden("bi_id", $this->bib["bi_id"]->value); + $form->addHidden("op", "editCat"); + $form->addHTML("" . getConstVar("EDIT_CAT_DATA") . ""); + $form->addHTML("
"); + $form->addHTML($this->fill_library_cat()); + $form->addHTML("
"); + $form->close(); + return $form->restituisci(); + } + + public function visualizza_dd_service() { + $form = new FieldsForm("form_library_serv"); + $form->addHidden("bi_id", $this->bib["bi_id"]->value); + $form->addHidden("op", "editServ"); + $form->addHTML("" . getConstVar("EDIT_DD_DATA") . ""); + $form->addHTML("
"); + $form->addHTML($this->fill_library_service()); + $form->addHTML("
"); + $form->addHTML("
"); + $form->addHTML($this->fill_suspension()); + $form->addHTML("
"); + $form->close(); + return $form->restituisci(); + } + + public function totReqLastYear() { + return $tot_richieste= $_SESSION['db']->fetch_single($_SESSION['db']->execute("SELECT SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel)+SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) + FROM `report_biblio` + WHERE bi_idrichie=".$this->bi_id." + AND ( + (re_mese BETWEEN ".getConstVar('MESE_INIZIO_CONTEGGIO')." AND 12 AND re_anno=".getConstVar('ANNO_INIZIO_CONTEGGIO').") + OR (re_mese BETWEEN 1 AND ".getConstVar('MESE_FINE_CONTEGGIO')." AND re_anno=".getConstVar('ANNO_FINE_CONTEGGIO').") + ) GROUP BY bi_idrichie ")); + } + + public function isOverQuota() { + if ($this->totReqLastYear() >= getConstVar('NUM_RICHIE_MAX')) + return true; + else + return false; + } + + public function isPublicLibrary() { + if ($this->tipo_ente != 5) + return true; + else + return false; + } + + public function kindOfContractLibrary($year) { + $lista_pr = $type = null; + $anno_arr = array(); + + foreach ($this->progetti as $key => $value) { + $lista_pr.=$key . ","; + } + if ($lista_pr != null) { + $lista_pr = substr($lista_pr, 0, -1); + $lista_pr = "pr_id IN ($lista_pr) OR "; + } + $res_aderente = $_SESSION['db']->execute("SELECT DISTINCT st_anno_contratto FROM storico_sottoscrizioni WHERE $lista_pr en_id=" . $this->en_id); + while ($anno = $_SESSION['db']->fetch($res_aderente)) { + $anno_arr[] = $anno['st_anno_contratto']; + } + if (in_array(($year - 1), $anno_arr)) + $type = getConstVar('ADERENTE_ANNO_PRECEDENTE'); + if (in_array($year, $anno_arr)) + $type = getConstVar('ADERENTE'); + if ($type != null) { + return $type; + } else { + if ($this->isPublicLibrary()) + return $type = getConstVar('SINGOLA_PUB'); + else + return $type = getConstVar('SINGOLA_PVT'); + } + } + + function updateOLDCatalogSettings() { + foreach ($this->DATAcat as $key_cat => $v_cat) { + if ($this->DATAcat[$key_cat]["partecipa"] == TRUE && $this->DATAcat[$key_cat]["tabella"] != NULL) { + $cat_attivo = strtolower($this->DATAcat[$key_cat]["ca_nome"]) . "_attivo"; + + $tabella = $this->DATAcat[$key_cat]["ca_tabella"]; + $nome = $this->DATAcat[$key_cat]["ca_nome"]; + $attivo = strtolower($nome) . "_attivo"; + + foreach ($this->DATAcat[$key_cat]["tabella"] as $key_tab => $v_tab) { + if (strpos($this->DATAcat[$key_cat]["tabella"][$key_tab]->fieldname, "_cod")) { + if ($this->bi_id > 0) { + $res = $_SESSION['db']->execute("SELECT $attivo from $tabella where bi_id=" . $this->bi_id . " AND $key_tab='" . $this->DATAcat[$key_cat]["tabella"][$key_tab]->value . "'"); + if ($res && $_SESSION['db']->numrows($res) == 1) { + $att_val = $_SESSION['db']->fetch_single($res); + $this->DATAcat[$key_cat]["tabella"][$cat_attivo]->value = $att_val; + } + } + } + } + } + } + } + +} +?> diff --git a/modules/bibliografia.php b/modules/bibliografia.php new file mode 100755 index 0000000..3e16d0d --- /dev/null +++ b/modules/bibliografia.php @@ -0,0 +1,464 @@ +execute( + "SELECT COUNT(rif.ri_id) + FROM refman ref, riferimento rif + WHERE rif.ri_id = ref.ri_id AND ref.rm_cancella = 0 AND rif.ri_id = any ( + SELECT rif_eti.ri_id + FROM rif_eti + WHERE rif_eti.et_id = " . $label . ")" + ); + + + $result = $_SESSION['db']->execute( + "SELECT rif.ri_id, ri_titolopub, ri_au1, ri_anno, rm_stato, ri_titolopart, rm_datarichie, rm_dataeva, rm_notebibute, rm_noteutebib, rm_cancella + FROM refman ref, riferimento rif + WHERE rif.ri_id = ref.ri_id AND ref.rm_cancella = 0 AND rif.ri_id = any ( + SELECT rif_eti.ri_id + FROM rif_eti + WHERE rif_eti.et_id = " . $label . ") + ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + } + else { + $result_count = $_SESSION['db']->execute( + "SELECT COUNT(ri_id) + FROM refman + WHERE ut_id = " . $idute . " AND rm_cancella = 0" + ); + + $result = $_SESSION['db']->execute( + "SELECT rif.ri_id, ri_titolopub, ri_au1, ri_anno, rm_stato, ri_titolopart, rm_datarichie, rm_dataeva, rm_notebibute, rm_noteutebib, rm_cancella + FROM refman ref, riferimento rif + WHERE ref.ut_id = " . $idute . " AND ref.rm_cancella = 0 AND ref.ri_id = rif.ri_id + ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + } + $arr = $_SESSION['db']->fetch($result_count, 2); + $max = $arr[0]; + $cols = $_SESSION['db']->numcols($result); + + for ($j = 0; $j < $cols; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + + $ret.=Bibliografia::navigation_bar($idute, $label, $start, $passo, $max); + + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.=" \n"; + $ret.=" \n"; + $ret.=" \n"; + $ret.=" \n"; + + for ($j = 1; $j < 5; $j++) { + if ($flds[$j] == $order) { + if ($qualif == "asc") + $ret.=" \n"; + else + $ret.=" \n"; + } else + $ret.=" \n"; + } + $ret.=" \n"; + $rowspan = 1 + $passo; + + if ($_SESSION['db']->numrows($result) == 0) + $dd_link = ""; + else + $ret.=" \n"; + + + $i = 0; + $query = "SELECT et_nome + FROM etichetta + WHERE et_id = any ( + SELECT et_id + FROM rif_eti + WHERE ri_id = ?)"; + $bibliografiaSTMT = $_SESSION['db']->prepareSTMT($query); + if (!$bibliografiaSTMT) { + echo 'Errore: creazione preparestatement per bibliografia'; + die; + } + if ($_SESSION['db']->numrows($result) == 0) + $ret.=""; + else + while ($row = $_SESSION['db']->fetch($result)) { + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $riid = $row[$flds[0]]; + $ret.="\n"; + + $idrif[$i] = $row["ri_id"]; + $ret.=Form::getCheckBox("idrif[]", $idrif[$i], "", null, "\n"); + + $ret.="\n"; + + $ret.="\n"; + + $ret.="\n"; + + $ret.="\n"; + + $ret.=" \n"; + + $ret.=" \n"; + $i++; + } + $bibliografiaSTMT->close(); + + $ret.="
" . getConstVar($flds[$j]) . "" . getConstVar($flds[$j]) . "" . getConstVar($flds[$j]) . "" . getConstVar("DD_INFOS") . "
" . getConstVar("NOREFERENCES") . "
", "\n"; + $ret.="
" . $row["ri_titolopub"] . "
" . $row["ri_titolopart"] . "
\n"; + $bibliografiaSTMT->bind_param('i', $idrif[$i]); + $bibliografiaSTMT->execute(); + $bibliografiaSTMT->bind_result($et_nome); + $first = TRUE; + $ret.="
\n"; + while ($bibliografiaSTMT->fetch()) { + if (!$first) + $ret.=" | "; + else + $first = FALSE; + $ret.="" . $et_nome . "\n"; + } + $ret.="
\n"; + + $ret.="
" . $row["ri_au1"] . "" . $row["ri_anno"] . "" . fieldrender::render("rm_stato", $row["rm_stato"]) . "\n"; + $ret.="
\n"; + + + if ($row["rm_stato"] == getConstVar("Rif_NonRichiesto")) { + if (isset($_SESSION['app_stato']) && !in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) + $ret.= " + + " . getConstVar("SUBMIT") . " + "; + else + $ret.=getConstVar('AVVISO_UTENTE_DISABILITATO_FUNZIONE_DD'); + } + elseif ($row["rm_stato"] == getConstVar("Rif_RichiestaAperta")) { + $ret.=FieldRender::render("rm_datarichie", $row["rm_datarichie"]); + $ret.=FieldRender::render("rm_noteutebib", $row["rm_noteutebib"]); + } elseif ($row["rm_stato"] == getConstVar("Rif_BiblioChiedeConferma")) { + $ret.=FieldRender::render("rm_datarichie", $row["rm_datarichie"]); + $ret.=FieldRender::render("rm_noteutebib", $row["rm_noteutebib"]); + $ret.="
Attenzione! Richiesta accettazione costo
"; + } elseif ($row["rm_stato"] == getConstVar("Rif_RichiestaChiusa_Eva")) { + $ret.="
" . getConstVar("DOC_RECEIVED_ON") . ": " . print_datetime($row["rm_dataeva"], "date") . "
\n"; + $ret.=FieldRender::render("rm_notebibute", $row["rm_notebibute"]); + } elseif ($row["rm_stato"] == getConstVar("Rif_RichiestaChiusa_Ineva")) { + $ret.="
" . getConstVar("DOC_NOT_DELIVERED") . ": " . print_datetime($row["rm_dataeva"], "date") . "
\n"; + $ret.=FieldRender::render("rm_notebibute", $row["rm_notebibute"]); + } + $ret.="
\n"; + $ret.="
\n"; + + $ret.=Bibliografia::navigation_bar_bottom($start, $passo, $max); + return $ret; + } + + public static function reference_list_tool($idute) { + $ret = ""; + $ret.="
\n"; + $res_request_limit = $_SESSION['db']->execute("SELECT COUNT(*) FROM docdel WHERE DATE_FORMAT(dd_lastmodify, '%c') = MONTH(NOW()) AND (dd_stato_borr = " . getConstVar("BORR_CONS_DIRETTA") . " OR dd_stato_borr = " . getConstVar("BORR_NUOVO") . ") AND ut_id = " . $_SESSION['utente']->ut_id); + $request_limit = $_SESSION['db']->fetch_single($res_request_limit); + switch ($_SESSION['utente']->ut_id) { + case '1': + $aaaa = "
" . getConstVar("dd_opereva") . ". -> " . $request_limit . getConstVar("dd_opereva_article_number") . "
"; + $ret .= $aaaa; + $ret.= " " . getConstVar("INSERT_NEW") . "\n"; + break; + default: + if ($request_limit >= getConstVar("ARTICLES_LIMIT_PER_MONTH")) { + $ret.="
" . getConstVar("ARTICLES_LIMIT_PER_MONTH_MSG") . "
"; + } else { + $ll = (int) getConstVar("ARTICLES_LIMIT_PER_MONTH") - (int) $request_limit; + $aaaa = "
" . getConstVar("ARTICLES_LIMIT_PER_MONTH_REST") . " " . $ll . "
"; + $ret .= $aaaa; + $ret.= " " . getConstVar("INSERT_NEW") . "\n"; + } + } + $ret.="
\n"; + $ret.=" " . getConstVar("DELETE_SELECTED") . "\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + return $ret; + } + + private static function navigation_bar($idute, $label, $start, $passo, $max) { + $ret = ""; + $ret.="
\n"; + $ret.=Bibliografia::label_filter($idute, $label, $passo); + $ret.=Bibliografia::nav_control($start, $passo, $max); + $ret.="
\n"; + return $ret; + } + + private static function navigation_bar_bottom($start, $passo, $max) { + $ret = ""; + $ret.="
\n"; + $ret.=Bibliografia::nav_control($start, $passo, $max); + $ret.="
\n"; + return $ret; + } + + private static function label_filter($idute, $label, $passo) { + $ret = ""; + $action = "onchange=\"javascript:update_references_by_label('action_bibliografia.php?op=aggiorna&start=0')\""; + // Ottiene l'elenco delle etichette per l'utente + $eti_arr = db_elenco("et_id", "ut_id=$idute"); + //DIADOSIS TEAM Added translation for all requests + $tutti = array("0" => getConstVar("ALL_REQ")); + $eti_vis = $tutti; + if ($eti_arr != null) + $eti_vis+=$eti_arr; + + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.=" " . getConstVar("DISPLAY_FILTER") . " \n"; + $ret.=Form::getSelect("label", FALSE, $eti_vis, $label, null, " style='display:none;' class=\"form-control\" $action", " ", "\n"); + $ret.=Bibliografia::range_select($passo); + $ret.=" " . getConstVar("AT_A_TIME") . " \n"; + $ret.="
\n"; + return $ret; + } + + /* --------------------------------------------- */ + + private static function nav_control($start, $passo, $max) { + $ret = ""; + $ret.="
\n"; + + $url = "javascript:update_references('action_bibliografia.php?op=aggiorna"; + $prev = ""; + $last = ""; + $first = ""; + $next = ""; + $intervall = ""; + + if ($max == 0) { + } else { + if ($start + $passo < $max) { + $pos = $start + $passo; + $intervall = ($start + 1) . " - $pos " . getConstVar("OF") . " $max\n"; + + $next = $url . "&start=" . $pos . "')"; + if ($max % $passo == 0) + $last = $max - $passo; + else + $last = $max - ($max % $passo); + $last = $url . "&start=" . $last . "')"; + + $ret.=" \">>\"\n"; + $ret.=" \">\"\n"; + $ret.="
\n"; + $ret.=" $intervall\n"; + $ret.="
\n"; + } + else { + $intervall = ($start + 1) . " - $max " . getConstVar("OF") . " $max\n"; + $ret.="
\n"; + $ret.=" $intervall\n"; + $ret.="
\n"; + } + + if ($start > 0) { + $first = $url . "&start=0')"; + $pre = $start - $passo; + $prev = $url . "&start=" . $pre . "')"; + $ret.=" \"<\"\n"; + $ret.=" \"<<\"\n"; + } + } + $ret.="
\n"; + return $ret; + } + + private static function range_select($passo) { + $action = "onchange=\"javascript:update_references_by_range('action_bibliografia.php?op=aggiorna&start=0')\""; + $passi["5"] = "5"; + $passi["10"] = "10"; + $passi["20"] = "20"; + $passi["100"] = "100"; + $ret = Form::getSelect("passo", FALSE, $passi, $passo, null, "style='width:100px; display:inline;' class=\"form-control\" $action", " ", "\n"); + return $ret; + } + + public static function print_list($post) { + + $num_sel = count($post["idrif"]); + for ($i = 0; $i < $num_sel; $i++) { + + $result = $_SESSION['db']->execute( + "SELECT * + FROM riferimento + WHERE ri_id = " . $post["idrif"][$i] + ); + + $cols = $_SESSION['db']->numcols($result); + for ($j = 0; $j < $cols; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $row = $_SESSION['db']->fetch($result); + echo "
" . $row["ri_au1"] . " " . $row["ri_au2"] . ",
Article: " . $row["ri_titolopart"] . ",
Journal: " . $row["ri_titolopub"] . ",
Vol " . $row["ri_vol"] . " (" . $row["ri_fasc"] . ") pp " . $row["ri_pagini"] . "-" . $row["ri_pagini"] . + (!is_null($row["ri_doi"]) ? "
DOI: " . $row["ri_doi"] : "") . + (!is_null($row["ri_pmid"]) ? "
PubMed ID: " . $row["ri_pmid"] : "") . + "

\n"; + } + } + + public static function label_manager($idute) { + $ret = ""; + $ret.="
\n"; + + $ret.="
\n"; + $ret.="
\n"; + $ret.=Bibliografia::label_select($idute); + $ret.="
\n"; + $ret.="
\n"; + return $ret; + } + + private static function label_select($idute) { + $ret = ""; + $ret.="
\n"; + $eti_arr = db_elenco("et_id", "ut_id=$idute"); + $ret.=Form::getSelect("eti_coll", FALSE, $eti_arr, $_SESSION['label'], null, "class=\"form-control\"", "", "\n"); + + $ret.=" " . getConstVar("APPLY") . "\n"; + $ret.=" " . getConstVar("REMOVE") . "\n"; + $ret.="
\n"; + return $ret; + } + + public static function getLabelOptions($idute, $selected_index = null) { + $eti_arr = db_elenco("et_id", "ut_id=$idute"); + return Form::getSelectOptions($eti_arr, $selected_index); + } + + public static function label_creator($idute) { + $myeti = db_elenco("et_id", "ut_id=$idute"); + $eticount = sizeof($myeti); + + $ret = "
+
+ +
+
+
+ " . getConstVar("LABELS_CREATED") . " $eticount " . getConstVar("LABELS") + . " / " . getConstVar("MAX_USER_LABELS") . ". +
+ "; + if ($eticount < getConstVar("MAX_USER_LABELS")) { + $et = new Etichetta(); + $ret.=$et->nuovo(); + } + $ret.=" "; + if ($eticount == 0) + $ret.=" + + + "; + else { + foreach ($myeti as $label_id => $label_name) { + $ret.= " + + + "; + } + } + $ret.="
" . getConstVar("NOETI") . ".
+ "; + $ret.=Etichetta::render($label_id, $label_name); + + $ret.= "
+
+ "; + return $ret; + } + + public static function history_dd($idute) { + + $result = $_SESSION['db']->execute( + "SELECT ri_titolopub, ri_titolopart, ri_au1, ri_anno, rm_datarichie, rm_dataeva + FROM refman ref, riferimento rif + WHERE ref.ut_id = " . $idute . " AND rm_stato != " . getConstVar("Rif_NonRichiesto") . " AND rm_stato != " . getConstVar("Rif_RichiestaAperta") . " AND ref.ri_id = rif.ri_id + ORDER BY rm_datarichie DESC" + ); + + echo "\n"; + $cols = $_SESSION['db']->numcols($result); + for ($j = 0; $j < $cols; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + + echo "\n"; + for ($j = 0; $j < 5; $j++) + echo "\n"; + echo "\n"; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + if ($i % 2 == 0) + $c = "item1"; + else + $c = "item2"; + echo "\n"; + for ($j = 0; $j < 5; $j++) + echo "\n"; + echo "\n"; + $i++; + } + + echo "
- " . $flds[$j] . " -
" . $row[$flds[$j]] . "
" . "\n"; + } + + public static function reference_summary($idute) { + $ref_count = $_SESSION['db']->execute( + "SELECT count( rm_id ) AS num , rm_stato + FROM `refman` + WHERE ut_id=" . $idute . " + GROUP BY rm_stato + ORDER BY rm_stato" + ); + + $num_status[getConstVar("Rif_NonRichiesto")] = 0; + $num_status[getConstVar("Rif_RichiestaAperta")] = 0; + $num_status[getConstVar("Rif_BiblioChiedeConferma")] = 0; + $num_status[getConstVar("Rif_RichiestaChiusa_Eva")] = 0; + $num_status[getConstVar("Rif_RichiestaChiusa_Ineva")] = 0; + + if ($_SESSION['db']->numrows($ref_count) != 0) { + while ($row = $_SESSION['db']->fetch($ref_count)) { + $num_status[$row["rm_stato"]] = $row["num"]; + } + } + $num_status[getConstVar("Rif_Tutti_Req")] = $num_status[getConstVar("Rif_RichiestaAperta")] + $num_status[getConstVar("Rif_BiblioChiedeConferma")] + $num_status[getConstVar("Rif_RichiestaChiusa_Eva")] + $num_status[getConstVar("Rif_RichiestaChiusa_Ineva")]; + $num_status[getConstVar("Rif_Tutti")] = $num_status[getConstVar("Rif_Tutti_Req")] + $num_status[getConstVar("Rif_NonRichiesto")]; + return $num_status; + } + +} + +?> diff --git a/modules/borrowing.php b/modules/borrowing.php new file mode 100755 index 0000000..c632148 --- /dev/null +++ b/modules/borrowing.php @@ -0,0 +1,2327 @@ +cat = isset($_SESSION['cataloghi']) ? $_SESSION['cataloghi'] : null; + $this->gruppi = isset($_SESSION['gruppi']) ? $_SESSION['gruppi'] : null; + $this->preselbib = $idbibforni; + + $this->borr_dd = $_SESSION['db']->fetch_fields("docdel"); + + if ($id != null) { + $result_dd = $_SESSION['db']->execute("SELECT * FROM docdel WHERE dd_id=$id"); + if ($result_dd && $_SESSION['db']->numrows($result_dd) == 1) { + $dati_dd = $_SESSION['db']->fetch($result_dd); + foreach ($this->borr_dd as $key => $v) { + $this->borr_dd[$key]->value = $dati_dd[$key]; + } + parent::__construct($this->borr_dd["ri_id"]->value, null); + + if ($this->isUserRequest()) { + $campirefman = "rm_id, ri_id, rm_stato, rm_datarichie, rm_dataeva, rm_noteutebib, rm_notebibute, rm_polcosti"; + $this->borr_rm = $_SESSION['db']->fetch_fields("refman", $campirefman); + $result_rm = $_SESSION['db']->execute("SELECT " . $campirefman . " + FROM refman + WHERE ri_id=" . $this->borr_dd["ri_id"]->value); + if ($result_rm && $_SESSION['db']->numrows($result_rm) == 1) { + $dati_rm = $_SESSION['db']->fetch($result_rm); + foreach ($this->borr_rm as $key => $v) { + $this->borr_rm[$key]->value = $dati_rm[$key]; + } + } + } + } + } elseif ($rif_type != null) { + $this->borr_dd["bi_idrichie"]->value = $idbibrichie; + $this->borr_dd["dd_stato_borr"]->value = getConstVar("BORR_NUOVO"); + $this->borr_dd["dd_stato_ddill"]->value = getConstVar("DDILL_NO_DDILL"); + $this->borr_rm = $_SESSION['db']->fetch_fields("refman"); + parent::__construct(null, $rif_type); + } + } + + function __destruct() { + parent::__destruct(); + unset($this->borr_dd); + unset($this->borr_rm); + unset($this->preselbib); + unset($this->primaricsett); + unset($this->cat); + unset($this->gruppi); + unset($this->controllo); + } + + public function __get($fieldname) { + if (isset($this->borr_dd[$fieldname])) + return $this->borr_dd[$fieldname]->value; + + elseif (isset($this->borr_rm[$fieldname])) + return $this->borr_rm[$fieldname]->value; + + elseif (isset($this->rif[$fieldname])) + return $this->rif[$fieldname]->value; + } + + public function __set($fieldname, $value) { + if (isset($this->borr_dd[$fieldname])) + $this->borr_dd[$fieldname]->value = $value; + + if (isset($this->borr_rm[$fieldname])) + $this->borr_rm[$fieldname]->value = $value; + + if (isset($this->rif[$fieldname])) + $this->rif[$fieldname]->value = $value; + } + + public function set_parse($fieldname, $post) { + $flds = new ParserField($post); + $value = $flds->simple_parse($this->borr_dd[$fieldname]); + $this->borr_dd[$fieldname]->value = $value; + } + + public function get_controllo() { + return $this->controllo; + } + + public function reset_controllo() { + $this->controllo = array(); + } + + public function isNewRequest() { + return ($this->borr_dd["ri_id"]->value == "" || !isset($this->borr_dd["ri_id"]->value)); + } + + public function isUserRequest() { + return ($this->borr_dd["ut_id"]->value != ""); + } + + function nuovo_openurl($tipo) { + parent::parse_openurl($tipo); + $this->componi_pannello(); + } + + public function elimina() { + if (check_lastmodify($this)) { + $del_ok = parent::elimina(); + if ($del_ok) { + $query = "delete from docdel WHERE dd_id=" . $this->borr_dd["dd_id"]->value; + $result = $_SESSION['db']->execute($query); + return $result; + } + } else + return getConstVar("ERROR_LASTMODIFY"); + } + + public function aggiornaObject($post) { + if (isset($post["ri_titolopub"])) { + parent::aggiornaObject($post); + } + } + + public function aggiornaDB() { + + if (check_lastmodify($this)) { + parent::aggiornaDB(); + + $coppie = ""; + $coppie_rm = ""; + foreach ($this->borr_dd as $key => $v) { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . ParserField::quote($this->borr_dd[$key]); + } + + if ($coppie != "") { + $query = "UPDATE docdel SET $coppie WHERE dd_id=" . $this->borr_dd["dd_id"]->value; + $result = $_SESSION['db']->execute($query); + } + + if ($result) { + if ($this->isUserRequest()) { + foreach ($this->borr_rm as $key => $v) { + if ($coppie_rm != "") + $coppie_rm.=","; + if ($key == "rm_dataeva") + $coppie_rm.=$key . "=NOW()"; + else + $coppie_rm.=$key . "=" . ParserField::quote($this->borr_rm[$key]); + } + + if ($coppie_rm != "") { + $query_rm = "UPDATE refman SET $coppie_rm WHERE rm_id=" . $this->borr_rm["rm_id"]->value; + $result_rm = $_SESSION['db']->execute($query_rm); + if (!$result_rm) + return FALSE; + } + } + + return TRUE; + } else + return FALSE; + } else + return getConstVar("ERROR_LASTMODIFY"); + } + + public function inserisciDB() { + + if ($this->borr_dd["ri_id"]->value == "") + $idrif = parent::inserisciDB(); + else + $idrif = $this->borr_dd["ri_id"]->value; + + if ($idrif != null) { + $this->borr_dd["ri_id"]->value = $idrif; + $attributi = ""; + $valori = ""; + + foreach ($this->borr_dd as $key => $v) { + if ($attributi != "") + $attributi.=","; + if ($valori != "") + $valori.=","; + + $attributi.=$key; + $valori.=ParserField::quote($this->borr_dd[$key]); + } + + if ($attributi != "") { + $result = $_SESSION['db']->execute("INSERT INTO docdel ($attributi) VALUES($valori)"); + $lastid = $_SESSION['db']->last_id(); + if ($result) { + if ($this->isUserRequest() && $this->borr_dd["dd_stato_borr"]->value == getConstVar("BORR_ATTESA_ACCETTA_UTE_FN")) { + $query_rm = "UPDATE refman SET rm_stato=" . $this->borr_rm["rm_stato"]->value . " WHERE rm_id=" . $this->borr_rm["rm_id"]->value; + $result_rm = $_SESSION['db']->execute($query_rm); + if (!$result_rm) + return FALSE; + } + return $lastid; + } else + return FALSE; + } else + return FALSE; + } else + return FALSE; + } + + public function download_file() { + $file = getConstVar("UPLOAD_DIR") . $this->borr_dd["dd_file"]->value; + + download($file); + } + + public function download_hc_file() { + $file = getConstVar("HC_UPLOAD_DIR") . $this->borr_dd["dd_file"]->value; + + download($file); + } + + public function elimina_file() { + $file = getConstVar("UPLOAD_DIR") . $this->borr_dd["dd_file"]->value; + $pathinfo = pathinfo($file); + if (strtolower($pathinfo["extension"]) == 'pdf') { + $file_copy = getConstVar("UPLOAD_DIR") . $pathinfo["filename"] . "_copyright.pdf"; + @unlink($file_copy); + } + @unlink($file); + $file3 = getConstVar("HC_UPLOAD_DIR") . $this->borr_dd["dd_file"]->value; + @unlink($file3); + } + + public function componi_pannello() { + + $this->reset_controllo(); + + echo "
+
"; + if ($this->isUserRequest()) + echo $this->box_datiutente(); + + $this->box_track(); + + echo $this->box_bottoni_chiusura(); + $form = new FieldsForm("form_richiesta"); + $form->addHTML(""); + + $this->box_riferimento($form); + + $this->box_bottoni($form); + + $form->close(); + $form->stampa(); + + echo "
"; + } + + public function box_bottoni_chiusura($nocontrol = false) { + + $bott = ""; + $stato_bor = $this->borr_dd["dd_stato_borr"]->value; + $stato_ddill = $this->borr_dd["dd_stato_ddill"]->value; + if (($stato_bor == getConstVar("BORR_ATTESA_ACCETTA_UTE_FN")) || + ($stato_bor == getConstVar("BORR_UTE_ACCETTA_FN")) || + (($stato_bor == getConstVar("BORR_INOLTRATO")) && $stato_ddill == getConstVar("DDILL_INOLT_NILDE")) || + (($stato_bor == getConstVar("BORR_INOLTRATO")) && $stato_ddill == getConstVar("DDILL_RICHIESTO_ANNULLA")) || + (($stato_bor == getConstVar("BORR_INOLTRATO")) && $stato_ddill == getConstVar("DDILL_ELABORA_SERVER")) || + ($stato_bor == getConstVar("BORR_DOWNLOAD")) || + ($stato_bor == getConstVar("BORR_RICEVUTO"))) { + + $bott.="
"; + + $bott.="
"; + } + elseif (!$nocontrol) { + $bott = "
"; + $bott.=""; + $bott.=""; + $bott.="
"; + + $bott.="
"; + $bott.=""; + $bott.=""; + $bott.="
"; + } + else { + $bott = "
"; + $bott.=""; + $bott.=""; + $bott.="
"; + + $bott.="
"; + $bott.=""; + $bott.=""; + $bott.="
"; + } + + + + return $bott; + } + + public function box_datiutente() { + + $result = $_SESSION['db']->execute( + "SELECT ut_nome, ut_cognome + FROM utente + WHERE ut_id = " . $this->borr_dd["ut_id"]->value + ); + $utidtmp = $this->borr_dd["ut_id"]->value; + $user = $_SESSION['db']->fetch_row($result, 0); + switch ($this->borr_dd['dd_stato_accetta']->value) { + case 3: + $extra_polcosti = "" . getConstVar("FN_UTE_RIFIUTA") . "\n"; + break; + + case 2: + $extra_polcosti = "" . getConstVar("FN_UTE_ACCETTA") . "\n"; + break; + case 4: + $extra_polcosti = "" . getConstVar("FN_UTE_NONRISP") . "\n"; + break; + + default: + $extra_polcosti = null; + break; + } + + $polcosti = "
" . getConstVar("rm_polcosti_" . $this->borr_rm["rm_polcosti"]->value) . "$extra_polcosti
"; + $ret = "
+
+ + " . getConstVar("REQ_BY") . " " . $user["ut_nome"] . " " . $user["ut_cognome"] . " + + - " . print_datetime($this->borr_dd["rm_datarichie"]->value, "date") . " + - " . FieldRender::renderField($this->borr_dd["rm_countbib"]) . " + +
+
+
+ " . FieldRender::renderField($this->borr_rm["rm_noteutebib"]) . " +
+ $polcosti +
+
"; + return $ret; + } + + public function box_track() { + if (!$this->isUserRequest()) + echo "
"; + echo tracking::track_list($this->borr_dd["ri_id"]->value); + } + + public function box_riferimento($form) { + $stato_bor = $this->borr_dd["dd_stato_borr"]->value; + $stato_ddill = $this->borr_dd["dd_stato_ddill"]->value; + + if (($stato_bor == getConstVar("BORR_ATTESA_ACCETTA_UTE_FN")) || + ($stato_bor == getConstVar("BORR_UTE_ACCETTA_FN")) || + (($stato_bor == getConstVar("BORR_INOLTRATO")) && $stato_ddill == getConstVar("DDILL_INOLT_NILDE")) || + (($stato_bor == getConstVar("BORR_INOLTRATO")) && $stato_ddill == getConstVar("DDILL_RICHIESTO_ANNULLA")) || + (($stato_bor == getConstVar("BORR_INOLTRATO")) && $stato_ddill == getConstVar("DDILL_ELABORA_SERVER")) || + ($stato_bor == getConstVar("BORR_DOWNLOAD")) || + ($stato_bor == getConstVar("BORR_RICEVUTO"))) + $this->box_riferimento_visualizza($form); + else + $this->box_riferimento_edit($form); + } + + public function box_riferimento_edit($form) { + $form->addHTML("
"); + $new = true; + $controllo_rif = parent::addFormFields($form, $new); + $this->controllo = array_merge($this->controllo, $controllo_rif); + $form->addHTML("
"); + } + + public function box_riferimento_visualizza($form) { + $form->addHTML("
"); + $form->addHTML(parent::visualizza_intestazione()); + $form->addHTML(parent::visualizza()); + $form->addHTML("
"); + } + + public function box_biblioteche($form) { + $form->addHTML("
+
+ + " . getConstVar("SELECT_LIBRARY_BOX") . " +
"); + + $_SESSION['biborder'] = "bi_rank"; + $_SESSION['bibqualif'] = "asc"; + $_SESSION['bibstart'] = "0"; + $_SESSION['bibpasso'] = "100"; + + $form->addHTML("
"); + $first = TRUE; + $_SESSION['tipo'] = "200"; + $form->addHTML(" +
"); + $form->addHTML($this->pannello_biblioteche($this->borr_dd["bi_idrichie"]->value, $_SESSION['tipo'], $_SESSION['biborder'], $_SESSION['bibqualif'], $_SESSION['bibstart'], $_SESSION['bibpasso'])); + $form->addHTML("
"); + $form->addHTML("
"); + $form->addHTML("
"); + } + + public function box_bottoni($form, $passo = 1) { + $form->addHTML("
"); + $stato_bor = $this->borr_dd["dd_stato_borr"]->value; + $stato_ddill = $this->borr_dd["dd_stato_ddill"]->value; + + if ($stato_bor == getConstVar("BORR_NUOVO") || $stato_bor == getConstVar("BORR_REINOLTRO")) { + if ($passo == 1) { + // DIADOSIS TEAM: not display "user buttons" where request is new/forwarded + if (($stato_bor != getConstVar("BORR_REINOLTRO")) && ($this->isUserRequest())) + $this->box_bottoni_consegna_diretta_ute($form); + + else + if (($stato_bor != getConstVar("BORR_REINOLTRO")) && !($this->isUserRequest()) && ($this->borr_dd["dd_id"]->value != "")) + $this->box_bottoni_elimina($form); + else + $this->box_bottoni_empty($form); + $this->box_bottoni_avanti($form); + } + else if ($passo == 2) { + $this->box_bottoni_richiediNILDE($form, "nuovo_richiedi_nilde"); + $this->box_bottoni_indietro($form); + } + } elseif ($stato_bor == getConstVar("BORR_INOLTRATO")) { + if ($stato_ddill == getConstVar("DDILL_INOLT_FN")) + $this->box_bottoni_evasione_FN($form); + elseif ($stato_ddill == getConstVar("DDILL_INOLT_NILDE")) + $this->box_bottoni_richiedi_annullamento($form); + } + + + elseif ($stato_bor == getConstVar("BORR_UTE_ACCETTA_FN")) { + $this->box_bottoni_richiediFN_Conferma($form); + } elseif (($stato_bor == getConstVar("BORR_DOWNLOAD")) && evaso_nilde($stato_ddill)) { + if ($passo == 1) + $this->box_bottoni_download($form); + elseif ($passo == 2) { + if (($this->isUserRequest())) + $this->box_bottoni_consegna($form); + else + $this->box_bottoni_archivia_ricevuto($form); + $this->box_bottoni_cestina($form); + } + } + + elseif ($stato_bor == getConstVar("BORR_RICEVUTO")) { + if (($this->isUserRequest())) + $this->box_bottoni_consegna($form); + else + $this->box_bottoni_archivia_ricevuto($form); + + $this->box_bottoni_cestina($form); + } + + elseif ($stato_bor == getConstVar("BORR_UTE_RIFIUTA_FN") || + $stato_bor == getConstVar("BORR_NO_RICEVUTO") || + $stato_bor == getConstVar("BORR_CESTINATO")) { + + if ($passo == 1) { + if (($this->isUserRequest())) + $this->box_bottoni_no_consegna($form); + else { + if ($stato_bor == getConstVar("BORR_CESTINATO")) + $this->box_bottoni_archivia($form); + else + $this->box_bottoni_archivia_no_ricevuto($form); + } + $this->box_bottoni_reinoltra($form); + } + elseif ($passo == 2) { + $this->box_bottoni_richiediNILDE($form, "ripeti_richiedi_nilde"); + $this->box_bottoni_indietro($form); + } + + } elseif ($stato_bor == getConstVar('BORR_ATTESA_ACCETTA_UTE_FN')) { + $this->box_bottoni_utente_non_risponde($form); + } elseif ($stato_bor == getConstVar('BORR_UTE_NORISP')) { + $this->box_bottoni_consegna_diretta_ute($form); + $this->box_bottoni_richiediFN_Conferma($form); + } + $form->addHTML("
"); + } + + public function box_bottoni_consegna_diretta_ute($form) { + $form->addHTML("
" . getConstVar("UPLOAD_BOX_INFO") . " + borr_dd["dd_id"]->value . "\"/> + +
+ +
+ +
+

"); + + + $form->addHTML("
"); + $controllo_note = $form->addField($this->borr_rm["rm_notebibute"]); + $this->controllo = array_merge($this->controllo, $controllo_note); + $form->addHTML("
+ + + + " . getConstVar("EVADI") . " + + + + + " . getConstVar("INEVADI") . " + + + +
+
+
+ "); + } + + public function box_bottoni_elimina($form) { + + $form->addHTML("
+
+ + \"\" + + " . getConstVar("ELIMINA") . " + + \"\" + +
+
+
+
+ "); + } + + public function box_bottoni_richiedi_annullamento($form) { + $form->addHTML("
+
+
+ + \"\" + + " . getConstVar("RICHIE_ANNULLA") . " + + \"\" + +
+
+
+ "); + } + + function box_bottoni_utente_non_risponde($form) { + $form->addHTML("
+
+
+ + \"\" + + " . getConstVar("UTENTE_NON_RISPONDE") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_empty($form) { + + $form->addHTML("
+
+
+
+
+
+ "); + } + + public function box_bottoni_avanti($form) { + + if (getConstVar("ACNP_ENABLED")) { + if ($this->ri_tipomateriale == getConstVar("TIPO_ARTICOLO")) + $jsAction = "choose_ISSN()"; + else if ($this->ri_tipomateriale == getConstVar("TIPO_LIBRO")) + $jsAction = "choose_ISBN()"; + } else + $jsAction = "passo2Borrowing()"; + + + $form->addHTML("
+ + \"\" + + " . getConstVar("AVANTI") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_reinoltra($form) { + if (getConstVar("ACNP_ENABLED")) { + if ($this->ri_tipomateriale == getConstVar("TIPO_ARTICOLO")) + $jsAction = "choose_ISSN()"; + else if ($this->ri_tipomateriale == getConstVar("TIPO_LIBRO")) + $jsAction = "choose_ISBN()"; + } else + $jsAction = "passo2Borrowing()"; + + $form->addHTML("
+ + \"\" + + " . getConstVar("REINOLTRA") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_indietro($form) { + $form->addHTML("
+
+ + \"\" + + " . getConstVar("INDIETRO") . " + + \"\" + +
+
+
+
+
+ "); + } + + public function box_bottoni_richiediNILDE($form, $action) { + + $form->addHTML("
"); + $controllo_note = $form->addField($this->borr_dd["dd_noterichforni"], null, null, null, 1); + $this->controllo = array_merge($this->controllo, $controllo_note); + $this->controllo = array_merge($this->controllo, $controllo_prot); + $controllo_collo = $form->addField($this->borr_dd["dd_collocazione"], null, null, null, 1); + $this->controllo = array_merge($this->controllo, $controllo_collo); + $controllo_ninventario = $form->addField($this->borr_dd["dd_ninventarioforni"], null, null, null, 1); + $this->controllo = array_merge($this->controllo, $controllo_ninventario); + + if ($action == "ripeti_richiedi_nilde") + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"], null, null, null, 1); + else + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"]); + $this->controllo = array_merge($this->controllo, $controllo_note_interne); + + $form->addHTML("
" . getConstVar("borrowing_legal_notice") . "
"); + $form->addHTML("
+ + \"\" + + " . getConstVar("INOLTRARIC") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_richiediFN($form, $action) { + + $form->addHTML("
"); + if ($this->isUserRequest()) { + switch ($this->borr_rm["rm_polcosti"]->value) { + + case getConstVar("POL_NON_ACCETTA") : + $form->addHTML("
" . getConstVar("rm_polcosti_" . $this->borr_rm["rm_polcosti"]->value) . "
"); + if ($action == "ripeti_") + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"], null, null, null, 1, null); + else + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"]); + + $this->controllo = array_merge($this->controllo, $controllo_proteva); + + if ($action == "ripeti_") + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"], null, null, null, 1, null); + else + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"]); + + $this->controllo = array_merge($this->controllo, $controllo_note_interne); + + $form->addHTML(" +
+ + \"\" + + " . getConstVar("INOLTRARIC_FN") . " + + \"\" + +
"); + if ($action == "ripeti_") + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"], null, null, null, 1, null); + else + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"]); + $this->controllo = array_merge($this->controllo, $controllo_costo); + + $form->addHTML(" € + +
+
+
+ + "); + break; + case getConstVar("POL_ACCETTA") : + $form->addHTML("
" . getConstVar("rm_polcosti_" . $this->borr_rm["rm_polcosti"]->value) . "
"); + if ($action == "ripeti_") + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"], null, null, null, 1, null); + else + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"]); + $this->controllo = array_merge($this->controllo, $controllo_proteva); + + if ($action == "ripeti_") + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"], null, null, null, 1, null); + else + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"]); + $this->controllo = array_merge($this->controllo, $controllo_note_interne); + $form->addHTML(" +
+ + \"\" + + " . getConstVar("INOLTRARIC_FN") . " + + \"\" + +
+ "); + if ($action == "ripeti_") + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"], null, null, null, 1, null); + else + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"]); + $this->controllo = array_merge($this->controllo, $controllo_costo); + + $form->addHTML(" € +
+
+
+ "); + break; + case getConstVar("POL_INFORMA") : + $displayinfobtn = "display:none;"; + $displayconfermabtn = ""; + if ($action != "ripeti_") { + if ($this->borr_dd["dd_costofuorinilde"]->value > 0) { + $displayinfobtn = ""; + $displayconfermabtn = "display:none;"; + } + } + + $form->addHTML("
" . getConstVar("rm_polcosti_" . $this->borr_rm["rm_polcosti"]->value) . "
"); + if ($action == "ripeti_") + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"], null, null, null, 1, null); + else + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"]); + + $this->controllo = array_merge($this->controllo, $controllo_proteva); + + if ($action == "ripeti_") + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"], null, null, null, 1, null); + else + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"]); + + $this->controllo = array_merge($this->controllo, $controllo_note_interne); + + $form->addHTML("
+
+ + \"\" + + " . getConstVar("INFORMA_UTENTE") . " + + \"\" + + + \"\" + + " . getConstVar("INOLTRARIC_FN") . " + + \"\" + +
+
+ "); + if ($action == "ripeti_") + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"], "onKeyUp=\"javascript: showInformaUteButton();\"", null, null, 1, null); + else + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"], "onKeyUp=\"javascript: showInformaUteButton();\""); + $this->controllo = array_merge($this->controllo, $controllo_costo); + + $form->addHTML(" € +
+
+
+ "); + break; + } + } + else { + if ($action == "ripeti_") + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"], null, null, null, 1, null); + else + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"]); + + $this->controllo = array_merge($this->controllo, $controllo_proteva); + + if ($action == "ripeti_") + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"], null, null, null, 1, null); + else + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"]); + + $this->controllo = array_merge($this->controllo, $controllo_note_interne); + + $form->addHTML(" +
+ + \"\" + + " . getConstVar("INOLTRARIC_FN") . " + + \"\" + +
+ "); + if ($action == "ripeti_") + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"], null, null, null, 1, null); + else + $controllo_costo = $form->addField($this->borr_dd["dd_costofuorinilde"]); + + $this->controllo = array_merge($this->controllo, $controllo_costo); + + + $form->addHTML(" € +
+
+
+ "); + } + + $form->addHTML(" +
" . + getConstVar("INDICAZIONE_GEST_FN") . " +
+
+
+ "); + } + + public function box_bottoni_richiediFN_Conferma($form) { + + $form->addHTML("
"); + $this->controllo = array_merge($this->controllo, $controllo_protric); + $controllo_proteva = $form->addField($this->borr_dd["dd_nproteva"]); + $this->controllo = array_merge($this->controllo, $controllo_proteva); + $controllo_note_interne = $form->addField($this->borr_dd["dd_note_interne"]); + $this->controllo = array_merge($this->controllo, $controllo_note_interne); + $form->addHTML(" +
+ + \"\" + + " . getConstVar("INOLTRARIC_FN") . " + + \"\" + +
" . getConstVar("dd_costofuorinilde") . ": " . $this->borr_dd["dd_costofuorinilde"]->value . " €
+
+
+
" . + getConstVar("INDICAZIONE_GEST_FN") . " +
+
+
+
+
+ "); + } + + public function box_bottoni_evasione_FN($form) { + $form->addHTML("
+
" . getConstVar("INDICAZIONE_RISP_FN") . "
+ "); + $_SESSION['dd_dataevaFN'] = 1; + $controllo_data = $form->addField($this->borr_dd["dd_dataeva"], null, null, null, null, 1); + $this->controllo = array_merge($this->controllo, $controllo_data); + + $form->addHTML("
+ + \"\" + + " . getConstVar("EVASA") . " + + \"\" + + + \"\" + + " . getConstVar("INEVASA") . " + + \"\" + +
+
+
+
+ "); + } + + public function box_bottoni_download($form) { + if (file_exists(getConstVar("UPLOAD_DIR") . $this->borr_dd["dd_file"]->value)) { + $form->addHTML("
+ +
+ " . getConstVar("download_legal_notice_warning") . " +
+
+ " . getConstVar("download_legal_notice") . " +
"); + + $form->addHTML(" + + \"\" + + " . getConstVar("VIS_PRINT") . " + + \"\" + "); + if ($this->borr_dd["dd_stato_ddill"]->value == getConstVar("DDILL_EVASO_NILDE_HC")) { + if (file_exists(getConstVar("HC_UPLOAD_DIR") . $this->borr_dd["dd_file"]->value)) + $form->addHTML(" + + \"\" + + " . getConstVar("VIS_PRINT_HC") . " + + \"\" + "); + } + + + $form->addHTML(" +
+
+
+ + \"\" + + " . getConstVar("AVANTI") . " + + \"\" + +
+
+
+ "); + } + else { + + $form->addHTML("
+
+ " . getConstVar("nofile_warning") . " +
+
+
+ + \"\" + + " . getConstVar("CESTINA") . " + + \"\" + +
+
+ +
+ "); + } + } + + public function box_bottoni_consegna($form) { + $form->addHTML("
"); + $controllo_note = $form->addField($this->borr_rm["rm_notebibute"]); + $this->controllo = array_merge($this->controllo, $controllo_note); + + $form->addHTML("
+ + \"\" + + " . getConstVar("EVADI") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_archivia_ricevuto($form) { + $form->addHTML("
+
+ + \"\" + + " . getConstVar("ARCHIVIA_RIC") . " + + \"\" + +
+
+
+
+ "); + } + + public function box_bottoni_cestina($form) { + $form->addHTML("
+ + \"\" + + " . getConstVar("CESTINA") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_no_consegna($form) { + $form->addHTML("
"); + + $controllo_note = $form->addField($this->borr_rm["rm_notebibute"]); + $this->controllo = array_merge($this->controllo, $controllo_note); + + $form->addHTML("
+ + \"\" + + " . getConstVar("INEVADI") . " + + \"\" + +
+
+
+ "); + } + + public function box_bottoni_archivia_no_ricevuto($form) { + $form->addHTML("
+
+ + \"\" + + " . getConstVar("ARCHIVIA_NO_RIC") . " + + \"\" + +
+
+
+
+ "); + } + + public function box_bottoni_archivia($form) { + $form->addHTML("
+
+ + \"\" + + " . getConstVar("ARCHIVIA_RIC") . " + + \"\" + + + \"\" + + " . getConstVar("ARCHIVIA_NO_RIC") . " + + \"\" + +
+
+
+
+ "); + } + + public function pannello_biblioteche($bi_idrichie, $tipo, $order, $qualif, $start, $passo) { + $dynamicCatalog = false; + switch ($tipo) { + case getConstVar("ELENCO_ACNP"): + $message = "MSG_ACNP"; + break; + case getConstVar("ELENCO_SBN"): + $message = "MSG_SBN"; + break; + case getConstVar("ELENCO_MAI"): + $message = "MSG_MAI"; + break; + case getConstVar("ELENCO_ALTRO"): + $message = "MSG_ALTRO"; + break; + case getConstVar("ELENCO_TUTTE"): + $message = "MSG_TUTTE"; + break; + case getConstVar("ELENCO_FUORI"): + $message = "MSG_FUORI"; + break; + default: + $dynamicCatalog = true; + $message = "MSG_BIBLIO_IN"; + break; + } + $ret = null; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + if ($dynamicCatalog) + $searchListTitle = getConstVar($message) . $this->cat[$tipo]["ca_nome"]; + else + $searchListTitle = getConstVar($message); + + $baloon_helpcat = ""; + $hlp_tit = getConstVar("HELP"); + $testo_buono = getConstVar("HELP_" . $tipo); + if ($testo_buono != null && $testo_buono != "") + $testo_tip = $testo_buono; + + $hlp_content = trim($testo_tip, "\r\n\0\t"); + $ret.="
$searchListTitle $baloon_helpcat
"; + + + if ($tipo == getConstVar("ELENCO_MAI")) + $ret.="
cat[$tipo]["ca_url"] . "\" target=\"_blank\">" . getConstVar("LINKMAI") . "
"; + + elseif (isset($this->cat[$tipo]["ca_url"]) && $this->cat[$tipo]["ca_url"] != "" && $this->cat[$tipo]["ca_url"] != null && $tipo != getConstVar("ELENCO_ALTRO") && $tipo != getConstVar("ELENCO_TUTTE") && $tipo != getConstVar("ELENCO_FUORI")) + $ret.="
cat[$tipo]["ca_url"] . "\" target=\"_blank\">" . getConstVar("LINKCAT") . "
"; + + $ret.="
"; + $ret.=" "; + $ret.="
"; + $ret.="
"; + return $ret; + } + + public function elenco($bi_idrichie, $tipo, $order, $qualif, $start, $passo) { + $listacataloghi = null; + foreach ($this->cat as $key => $v) { + $listacataloghi.=$key . ","; + } + $listacataloghi = substr($listacataloghi, 0, -1); + $listagruppi = null; + foreach ($this->gruppi as $key => $value) { + $listagruppi.=$key . ","; + } + $listagruppi = substr($listagruppi, 0, -1); + + $and_nome_biblio = null; + + if (isset($_SESSION['nomeFiltroBiblioteca']) && $_SESSION["nomeFiltroBiblioteca"] != "") { + $nameview = "biblioview_" . rand(0, 999999); + $view = $_SESSION["db"]->execute("CREATE VIEW $nameview AS + SELECT biblio.bi_id,CONCAT_WS('-',biblio.bi_nome,tab_acnp.acnp_cod,tab_sbn.sbn_cod) AS strhash from biblio LEFT JOIN tab_acnp ON biblio.bi_id = tab_acnp.bi_id LEFT JOIN tab_sbn ON biblio.bi_id =tab_sbn.bi_id"); + $resv = $_SESSION["db"]->execute("SELECT bi_id,strhash from $nameview WHERE strhash LIKE '%" . addslashes($_SESSION['nomeFiltroBiblioteca']) . "%'"); + $x = $_SESSION["db"]->execute("DROP VIEW $nameview"); + $lista = ""; + while ($row = $_SESSION['db']->fetch($resv)) + $lista.=$row["bi_id"] . ","; + + + if ($lista != "") { + $lista = substr($lista, 0, -1); + $and_nome_biblio = " AND biblio.bi_id IN ($lista) "; + } elseif ($_SESSION["nomeFiltroBiblioteca"] != "") { + $and_nome_biblio = " AND FALSE"; + } + } elseif (isset($_SESSION['optionCons']) && $_SESSION["optionCons"] == 0) { + $lista = ""; + $res = $_SESSION["db"]->execute("SELECT biblio.bi_id,tab_acnp.acnp_cod from biblio LEFT JOIN tab_acnp ON biblio.bi_id = tab_acnp.bi_id"); + while ($row = $_SESSION['db']->fetch($res)) + $array_res[$row['acnp_cod']] = $row['bi_id']; + + + foreach ($_SESSION['cataloghi_results']['ACNP_Array']['havePoss'] as $indice => $value) { + if ($value && + isset($array_res[$indice]) && + isset($_SESSION['cataloghi_results']['ACNP_Array']['consorziata'][$indice]) && + ($_SESSION['cataloghi_results']['ACNP_Array']['consorziata'][$indice] == 0 || sizeof($_SESSION['cataloghi_results']['ACNP_Array']['poss']['tx'][$indice]) > 0) + ) { + $lista.=$array_res[$indice] . ','; + } + } + if ($lista != "") { + $lista = substr($lista, 0, -1); + $and_nome_biblio = " AND biblio.bi_id IN ($lista) "; + } else { + $and_nome_biblio = " AND FALSE"; + } + } + + $result_max = null; + + switch ($tipo) { + + case getConstVar("ELENCO_ACNP"): + if ($this->ri_tipomateriale == getConstVar('TIPO_ARTICOLO')) { + if (isset($_SESSION['cataloghi_results']['ACNP'])) { + $queryCodBilbioACNP = $_SESSION['cataloghi_results']['ACNP']; + $arrayResultACNP = $_SESSION['cataloghi_results']['ACNP_Array']; + } else { + if ($this->ri_issn != '') { + $config = 'acnp_w_issn'; + $paramValue = $this->ri_issn; + } else { + $config = 'acnp_w_titolo'; + $paramValue = replace_accents($this->ri_titolopub); + } + $collection = null; + if (isset($_SESSION['ACNP_DOWN']) && !$_SESSION['ACNP_DOWN']) + $collection = marcResponder($config, $paramValue); + + $codeBibACNP = null; + $poss = null; + $arrayResultACNP = null; + $indice = null; + while ($collection != null && $record = $collection->next()) { + foreach ($record->getFields() as $tag => $subfields) { + switch ($tag) { + case '008': + if (substr($subfields->getData(), 38, 2) == 'co') + $ispaper = false; + else + $ispaper = true; + break; + + case '852': + foreach ($subfields->getSubfields() as $code => $value) { + if ($code == 'a') { + $indice = strtoupper(preg_replace('/\W.*/', '', substr($value, 5))); + $arrayResultACNP['codeBibACNP'][$indice] = $indice; + $arrayResultACNP['consorziata'][$indice] = 0; + $arrayResultACNP['gaps']['co'][$indice] = isset($arrayResultACNP['gaps']['co'][$indice]) == true ? $arrayResultACNP['gaps']['co'][$indice] : null; + $arrayResultACNP['gaps']['tx'][$indice] = isset($arrayResultACNP['gaps']['tx'][$indice]) == true ? $arrayResultACNP['gaps']['tx'][$indice] : null; + + $arrayResultACNP['note']['co'][$indice] = isset($arrayResultACNP['note']['co'][$indice]) == true ? $arrayResultACNP['note']['co'][$indice] : null; + $arrayResultACNP['note']['tx'][$indice] = isset($arrayResultACNP['note']['tx'][$indice]) == true ? $arrayResultACNP['note']['tx'][$indice] : null; + + $arrayResultACNP['poss']['co'][$indice] = isset($arrayResultACNP['poss']['co'][$indice]) == true ? $arrayResultACNP['poss']['co'][$indice] : null; + $arrayResultACNP['poss']['tx'][$indice] = isset($arrayResultACNP['poss']['tx'][$indice]) == true ? $arrayResultACNP['poss']['tx'][$indice] : null; + + $arrayResultACNP['embargo']['co'][$indice] = isset($arrayResultACNP['embargo']['co'][$indice]) == true ? $arrayResultACNP['embargo']['co'][$indice] : null; + $arrayResultACNP['embargo']['tx'][$indice] = isset($arrayResultACNP['embargo']['tx'][$indice]) == true ? $arrayResultACNP['embargo']['tx'][$indice] : null; + + $arrayResultACNP['detail']['co'][$indice] = isset($arrayResultACNP['detail']['co'][$indice]) == true ? $arrayResultACNP['detail']['co'][$indice] : null; + $arrayResultACNP['detail']['tx'][$indice] = isset($arrayResultACNP['detail']['tx'][$indice]) == true ? $arrayResultACNP['detail']['tx'][$indice] : null; + + $arrayResultACNP['collocazione']['co'][$indice] = isset($arrayResultACNP['collocazione']['co'][$indice]) == true ? $arrayResultACNP['collocazione']['co'][$indice] : null; + $arrayResultACNP['collocazione']['tx'][$indice] = isset($arrayResultACNP['collocazione']['tx'][$indice]) == true ? $arrayResultACNP['collocazione']['tx'][$indice] : null; + + $arrayResultACNP['havePoss'][$indice] = isset($arrayResultACNP['havePoss'][$indice]) == true ? $arrayResultACNP['havePoss'][$indice] : false; + } + if ($code == 'b') { + if ($ispaper) + $arrayResultACNP['collocazione']['tx'][$indice][] = render_posseduti(trim(substr($value, 5))); + else + $arrayResultACNP['collocazione']['co'][$indice][] = ' ' . getConstVar('COLL_COLLOCAZIONE') . ': ' . render_posseduti(trim(substr($value, 5))); + } + } + break; + + case '866': + foreach ($subfields->getSubfields() as $code => $value) { + if ($code == 'a') { + + if ($ispaper) { + $arrayResultACNP['poss']['tx'][$indice][] = $poss = '' . getConstVar('COLL_POSSEDUTO') . ': ' . render_posseduti(trim(substr($value, 5))); + } else { + $arrayResultACNP['poss']['co'][$indice][] = $poss = '' . getConstVar('COLL_POSSEDUTO') . ': ' . render_posseduti(trim(substr($value, 5))); + } + $havePoss = false; + if (isset($this->ri_anno) && $this->ri_anno != 0) { + $possArray = preg_split('/(\d\d\d\d-\d\d\d\d[;,.])|(\d\d\d\d[;,.,-])/', $poss, null, 3); + foreach ($possArray as $yearString) { + $from = null; + $to = null; + $yearString = trim($yearString, '.,;'); + if (substr($yearString, -1) == '-') { + $checkYear = preg_split('/-/', $yearString, null, 3); + $from = $checkYear[0]; + $to = date('Y'); + } else { + $checkYear = preg_split('/-/', $yearString, null, 3); + if (count($checkYear) == 2) { + $from = $checkYear[0]; + $to = $checkYear[1]; + } else { + $from = $to = $checkYear[0]; + } + } + if ($from <= $this->ri_anno && $this->ri_anno <= $to) { + $havePoss = true; + break; + } + } + } else { + $havePoss = true; + } + if (isset($arrayResultACNP['havePoss'][$indice]) && !$arrayResultACNP['havePoss'][$indice]) + $arrayResultACNP['havePoss'][$indice] = $havePoss; + } + elseif ($code == 'z') { + $infoPoss = preg_replace('/\W.*/', '', substr($value, 5)); + switch ($infoPoss) { + case 'gaps': + if ($ispaper) + $arrayResultACNP['gaps']['tx'][$indice][] = ' ' . getConstVar('COLL_LACUNE') . ': ' . render_posseduti(substr($value, 10)); + else + $arrayResultACNP['gaps']['co'][$indice][] = ' ' . getConstVar('COLL_LACUNE') . ': ' . render_posseduti(substr($value, 10)); + break; + case 'note': + if ($ispaper) + $arrayResultACNP['note']['tx'][$indice][] = ' ' . getConstVar('COLL_NOTE') . ': ' . render_posseduti(substr($value, 10)); + else + $arrayResultACNP['note']['co'][$indice][] = ' ' . getConstVar('COLL_NOTE') . ': ' . render_posseduti(substr($value, 10)); + break; + case 'record': + if ($ispaper) + $arrayResultACNP['record']['tx'][$indice][] = ' ' . getConstVar('COLL_LASTUPDATE') . ': ' . substr($value, 20); + else + $arrayResultACNP['record']['co'][$indice][] = ' ' . getConstVar('COLL_LASTUPDATE') . ': ' . substr($value, 20); + break; + case 'holding': + if ($ispaper) + $arrayResultACNP['detail']['tx'][$indice][] = ' ' . getConstVar('COLL_DETAILS') . ': ' . render_posseduti(substr($value, 22)); + else + $arrayResultACNP['detail']['co'][$indice][] = ' ' . getConstVar('COLL_DETAILS') . ': ' . render_posseduti(substr($value, 22)); + break; + case 'embargo': + if ($ispaper) + $arrayResultACNP['embargo']['tx'][$indice][] = ' ' . getConstVar('COLL_EMBARGO') . ': ' . render_posseduti(substr($value, 13)); + else + $arrayResultACNP['embargo']['co'][$indice][] = ' ' . getConstVar('COLL_EMBARGO') . ': ' . render_posseduti(substr($value, 13)); + break; + } + } + } + break; + } + } + } + + if (true) { + + } + + $queryCodACNPConsorziate = "SELECT DISTINCT co_ACNP FROM consorzi WHERE co_nome=UPPER(?)"; + $listaCodACNPConsorziate = $_SESSION['db']->prepareSTMT($queryCodACNPConsorziate); + + $queryCodBilbioACNP = null; + $consorziACNP = getConstVar('ARRAY_CONSORZI'); + + if (isset($arrayResultACNP['havePoss']) && sizeof($arrayResultACNP['havePoss']) > 0) { + + foreach ($arrayResultACNP['havePoss'] as $i => $test) { + + if ($test) { + if (in_array($arrayResultACNP['codeBibACNP'][$i], $consorziACNP)) { + $listaCodACNPConsorziate->bind_param('s', $arrayResultACNP['codeBibACNP'][$i]); + $listaCodACNPConsorziate->execute(); + $listaCodACNPConsorziate->bind_result($codACNPConsorziata); + while ($listaCodACNPConsorziate->fetch()) { + $arrayResultACNP['consorziata'][$codACNPConsorziata] = isset($arrayResultACNP['consorziata'][$codACNPConsorziata]) == true ? $arrayResultACNP['consorziata'][$codACNPConsorziata] + 1 : 1; + $arrayResultACNP['codeBibACNP'][$codACNPConsorziata] = strtoupper($codACNPConsorziata); + $arrayResultACNP['poss']['co'][$codACNPConsorziata][] = isset($arrayResultACNP['poss']['co'][$i][0]) == true ? $arrayResultACNP['poss']['co'][$i][0] : null; + $arrayResultACNP['poss']['tx'][$codACNPConsorziata] = isset($arrayResultACNP['poss']['tx'][$codACNPConsorziata]) == true ? $arrayResultACNP['poss']['tx'][$codACNPConsorziata] : null; + $arrayResultACNP['gaps']['co'][$codACNPConsorziata][] = isset($arrayResultACNP['gaps']['co'][$i][0]) == true ? $arrayResultACNP['gaps']['co'][$i][0] : null; + $arrayResultACNP['gaps']['tx'][$codACNPConsorziata] = isset($arrayResultACNP['gaps']['tx'][$codACNPConsorziata]) == true ? $arrayResultACNP['gaps']['tx'][$codACNPConsorziata] : null; + + $arrayResultACNP['note']['co'][$codACNPConsorziata][] = ' note: (' . $arrayResultACNP['codeBibACNP'][$i] . ')'; + $arrayResultACNP['note']['tx'][$codACNPConsorziata] = isset($arrayResultACNP['note']['tx'][$codACNPConsorziata]) == true ? $arrayResultACNP['note']['tx'][$codACNPConsorziata] : null; + + $arrayResultACNP['embargo']['co'][$codACNPConsorziata][] = isset($arrayResultACNP['embargo']['co'][$i][0]) == true ? $arrayResultACNP['embargo']['co'][$i][0] : null; + $arrayResultACNP['embargo']['tx'][$codACNPConsorziata] = isset($arrayResultACNP['embargo']['tx'][$codACNPConsorziata]) == true ? $arrayResultACNP['embargo']['tx'][$codACNPConsorziata] : null; + + $arrayResultACNP['collocazione']['co'][$codACNPConsorziata][] = isset($arrayResultACNP['collocazione']['co'][0]) == true ? $arrayResultACNP['collocazione']['co'][0] : null; + $arrayResultACNP['collocazione']['tx'][$codACNPConsorziata] = isset($arrayResultACNP['collocazione']['tx'][$codACNPConsorziata]) == true ? $arrayResultACNP['collocazione']['tx'][$codACNPConsorziata] : null; + + $arrayResultACNP['detail']['co'][$codACNPConsorziata][] = isset($arrayResultACNP['getails']['co'][$i][0]) == true ? $arrayResultACNP['getails']['co'][$i][0] : null; + $arrayResultACNP['detail']['tx'][$codACNPConsorziata] = isset($arrayResultACNP['getails']['tx'][$codACNPConsorziata]) == true ? $arrayResultACNP['getails']['tx'][$codACNPConsorziata] : null; + + $arrayResultACNP['havePoss'][$codACNPConsorziata] = true; + if ($codACNPConsorziata != $arrayResultACNP['codeBibACNP'][$i]) + $queryCodBilbioACNP.="'" . $codACNPConsorziata . "',"; + } + } else + $queryCodBilbioACNP.="'" . $arrayResultACNP['codeBibACNP'][$i] . "',"; + } + } + } + + $listaCodACNPConsorziate->close(); + $queryCodBilbioACNP = substr($queryCodBilbioACNP, 0, -1); + $_SESSION['cataloghi_results']['ACNP'] = $queryCodBilbioACNP; + $_SESSION['cataloghi_results']['ACNP_Array'] = $arrayResultACNP; + } + } + + if (isset($queryCodBilbioACNP) && $queryCodBilbioACNP != null) { + $patch = ""; + + $preselquery = ""; + $preselfilter = ""; + $preselcount = ""; + + if ($this->preselbib) { + + if ($start == 0) { + $preselfilter = "AND biblio.bi_id <> " . $this->preselbib; + $preselquery = "SELECT bi_nome, acnp_cod, bi_rank, biblio.bi_id, bi_indi, bi_cap, bi_citta,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio, tab_acnp + WHERE biblio.bi_id = tab_acnp.bi_id AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND bi_nilde=1 AND acnp_attivo=1 AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE biblio_gruppo.bi_id= biblio_catalogo.bi_id AND biblio_catalogo.ca_id=1 AND gr_id IN ($listagruppi) AND UPPER(tab_acnp.acnp_cod) IN ($queryCodBilbioACNP) + AND bc_attivo=1 AND biblio.bi_id=" . $this->preselbib . ")"; + } + } + + $qrytot = " FROM biblio, tab_acnp + WHERE biblio.bi_id = tab_acnp.bi_id AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND bi_nilde=1 AND acnp_attivo=1 + $and_nome_biblio + AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE biblio_gruppo.bi_id= biblio_catalogo.bi_id AND biblio_catalogo.ca_id=1 AND gr_id IN ($listagruppi) AND UPPER(tab_acnp.acnp_cod) IN ($queryCodBilbioACNP) + AND bc_attivo=1 $preselfilter)"; + + + $qry = "SELECT bi_nome, acnp_cod, bi_rank, biblio.bi_id, bi_indi, bi_cap, bi_citta,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio, tab_acnp + WHERE biblio.bi_id = tab_acnp.bi_id AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND bi_nilde=1 AND acnp_attivo=1 + $and_nome_biblio + AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE biblio_gruppo.bi_id= biblio_catalogo.bi_id AND biblio_catalogo.ca_id=1 AND gr_id IN ($listagruppi) AND UPPER(tab_acnp.acnp_cod) IN ($queryCodBilbioACNP) + AND bc_attivo=1 ) + ORDER BY $order $qualif + LIMIT $start, $passo"; + + if ($preselquery != "") { + $qry = "$preselquery UNION ($qry)"; + $order = ""; + $qrytot = "SELECT COUNT(*)+1" . $qrytot; + } else + $qrytot = "SELECT COUNT(*)" . $qrytot; + + $result = $_SESSION['db']->execute($qry); + $result_max = $_SESSION['db']->execute($qrytot); + }else { + $result = null; + } + + for ($j = 0; $j < 3; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $message = "MSG_ACNP"; + break; + + case getConstVar("ELENCO_SBN"): + + $issn = false; + if (isset($_SESSION['cataloghi_results']['SBN'])) { + $queryCodBiblioSBN = $_SESSION['cataloghi_results']['SBN']; + $arrayResultSBN = $_SESSION['cataloghi_results']['SBN_Array']; + } else { + + if ($this->ri_tipomateriale == getConstVar('TIPO_ARTICOLO')) { + if ($this->ri_issn != '') { + $config = 'sbn_c_issn'; + $param = $this->ri_issn; + $issn = true; + } else { + $config = 'sbn_c_titolo_articolo'; + $param = $this->ri_titolopub; + $issn = false; + } + } else { + if (isset($_SESSION['ri_docID']) && $_SESSION['ri_docID'] != '') { + $config = 'sbn_c_docid'; + $param = $_SESSION['ri_docID']; + } else if ($this->ri_isbn != '') { + $config = 'sbn_c_isbn'; + $param = $this->ri_isbn; + } else { + $config = 'sbn_c_titolo_monografia'; + $param = $this->ri_titolopub; + } + } + $arrayResultSBN = null; + $queryCodBiblioSBN = null; + $collection_SBN = marcResponder($config, $param); + if ($issn == true & $collection_SBN == null) + $collection_SBN = marcResponder('sbn_c_titolo_articolo', $this->ri_titolopub); + + while ($collection_SBN != null && $record = $collection_SBN->next()) { + foreach ($record->getFields() as $tag => $subfields) { + if ($tag == '899') { + foreach ($subfields->getSubfields() as $code => $value) { + switch ($code) { + case '1': + $indice = strtoupper(preg_replace('/\[[0-9]*\]: /', '', $value)); + $queryCodBiblioSBN.="'" . $indice . "',"; + $arrayResultSBN['codeBibSBN'][$indice] = $indice; + break; + + case '4': + $arrayResultSBN['poss'][$indice] = strtoupper(preg_replace('/\[[0-9]*\]: /', '', $value)); + break; + } + } + } + } + } + + + + $queryCodBiblioSBN = substr($queryCodBiblioSBN, 0, -1); + $_SESSION['cataloghi_results']['SBN'] = $queryCodBiblioSBN; + $_SESSION['cataloghi_results']['SBN_Array'] = $arrayResultSBN; + } + + if ($queryCodBiblioSBN != null && $queryCodBiblioSBN != '') { + + $result_max = $_SESSION['db']->execute( + "SELECT COUNT(*) + FROM biblio, tab_sbn + WHERE biblio.bi_id = tab_sbn.bi_id + $and_nome_biblio + AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + AND bi_nilde=1 + AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE biblio_gruppo.bi_id= biblio_catalogo.bi_id AND biblio_catalogo.ca_id=2 AND gr_id IN (" . $listagruppi . ") + AND UPPER(tab_sbn.sbn_cod) IN ($queryCodBiblioSBN) + AND bc_attivo = 1 )" + ); + + $result = $_SESSION['db']->execute( + "SELECT bi_nome, sbn_cod,bi_rank, biblio.bi_id, bi_indi, bi_cap, bi_citta,sbn_cod_polo,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio, tab_sbn + WHERE biblio.bi_id = tab_sbn.bi_id + $and_nome_biblio + AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + AND bi_nilde=1 + AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE biblio_gruppo.bi_id= biblio_catalogo.bi_id AND biblio_catalogo.ca_id=2 AND gr_id IN (" . $listagruppi . ") + AND UPPER(tab_sbn.sbn_cod) IN ($queryCodBiblioSBN) + AND bc_attivo = 1 ) + ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + } else + $result = null; + for ($j = 0; $j < 3; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + + $message = "MSG_SBN"; + break; + + case getConstVar("ELENCO_MAI"): + $result_max = $_SESSION['db']->execute( + "SELECT COUNT(*) + FROM biblio, biblio_catalogo as bc + WHERE bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND biblio.bi_id = bc.bi_id AND bc.ca_id=3 AND bi_nilde=1 + $and_nome_biblio + AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio + WHERE gr_id IN (" . $listagruppi . ") + )" + ); + + $result = $_SESSION['db']->execute( + "SELECT bi_nome, bi_rank, biblio.bi_id, bi_indi, bi_cap, bi_citta, bi_opac,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio, biblio_catalogo as bc + WHERE bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND biblio.bi_id = bc.bi_id AND bc.ca_id=3 AND bi_nilde=1 + $and_nome_biblio + AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio + WHERE gr_id IN (" . $listagruppi . ") + ) + ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + + for ($j = 0; $j < 2; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $message = "MSG_MAI"; + break; + + case getConstVar("ELENCO_ALTRO"): + $result_max = $_SESSION['db']->execute( + "SELECT COUNT(*) + FROM biblio + WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + $and_nome_biblio + AND bi_id IN ( + SELECT DISTINCT(bi_id) + FROM biblio_gruppo + WHERE gr_id IN (" . $listagruppi . ")) + AND bi_id NOT IN ( + SELECT bi_id + FROM biblio_catalogo + WHERE bc_attivo = 1 AND ca_id IN (" . $listacataloghi . ") + ) + " + ); + + $result = $_SESSION['db']->execute( + "SELECT bi_nome, bi_rank, bi_id, bi_indi, bi_cap, bi_citta, bi_opac,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio + WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + $and_nome_biblio + AND bi_id IN ( + SELECT DISTINCT(bi_id) + FROM biblio_gruppo + WHERE gr_id IN (" . $listagruppi . ")) + AND bi_id NOT IN ( + SELECT bi_id + FROM biblio_catalogo + WHERE bc_attivo = 1 AND ca_id IN (" . $listacataloghi . ") + ) + + ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + for ($j = 0; $j < 2; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $message = "MSG_ALTRO"; + break; + + case getConstVar("ELENCO_TUTTE"): + $result_max = $_SESSION['db']->execute( + "SELECT COUNT(*) + FROM biblio + WHERE bi_id IN ( + SELECT DISTINCT(bi_id) + FROM biblio_gruppo + WHERE gr_id IN (" . $listagruppi . ") + ) + $and_nome_biblio + AND bi_nilde = 1 + AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + AND bi_id=" . getConstVar("ID_HEALLIBRARY") + ); + + $result = $_SESSION['db']->execute( + "SELECT bi_nome, bi_rank, bi_id, bi_indi, bi_cap, bi_citta,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio + WHERE bi_id IN ( + SELECT DISTINCT(bi_id) + FROM biblio_gruppo + WHERE gr_id IN (" . $listagruppi . ") + ) + $and_nome_biblio + AND bi_nilde = 1 + AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + AND bi_id <> $bi_idrichie + AND bi_id=" . getConstVar("ID_HEALLIBRARY") + . " ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + $flds = array(); + $flds[0] = $_SESSION['db']->fieldname($result, 0); + $flds[1] = getConstVar("CATALOGHI"); + $flds[2] = $_SESSION['db']->fieldname($result, 1); + + $message = "MSG_TUTTE"; + break; + + case getConstVar("ELENCO_FUORI"): + $result_max = $_SESSION['db']->execute( + "SELECT COUNT(*) FROM biblio WHERE bi_nilde=0 $and_nome_biblio"); + + $result = $_SESSION['db']->execute( + "SELECT bi_nome, bi_id, bi_indi, bi_cap, bi_citta,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio + WHERE bi_nilde=0 $and_nome_biblio + GROUP BY bi_id + ORDER BY " . $order . " " . $qualif . " LIMIT " . $start . ", " . $passo); + + for ($j = 0; $j < 1; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $message = "MSG_FUORI"; + break; + + default: + + $result_max = $_SESSION['db']->execute( + "SELECT COUNT(*) + FROM biblio, " . $this->cat[$tipo]["ca_tabella"] . " + WHERE biblio.bi_id = " . $this->cat[$tipo]["ca_tabella"] . ".bi_id AND " . $this->cat[$tipo]["ca_tabella"] . "." . substr($this->cat[$tipo]["ca_tabella"], 4) . "_attivo = 1 AND biblio.bi_id <>" . $bi_idrichie . " + AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE gr_id IN (" . $listagruppi . ") + AND bc_attivo )" + ); + + $result = $_SESSION['db']->execute( + "SELECT bi_nome," . substr($this->cat[$tipo]["ca_tabella"], 4) . "_cod, bi_rank,biblio.bi_id, bi_indi, bi_cap, bi_citta,bi_sospini, bi_sospfine,bi_preavvisososp + FROM biblio, " . $this->cat[$tipo]["ca_tabella"] . " + WHERE biblio.bi_id = " . $this->cat[$tipo]["ca_tabella"] . ".bi_id AND " . $this->cat[$tipo]["ca_tabella"] . "." . substr($this->cat[$tipo]["ca_tabella"], 4) . "_attivo = 1 AND biblio.bi_id <>" . $bi_idrichie . " + AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND biblio.bi_id IN ( + SELECT DISTINCT(biblio_gruppo.bi_id) + FROM biblio_gruppo, biblio_catalogo + WHERE gr_id IN (" . $listagruppi . ") + AND bc_attivo ) + ORDER BY " . $order . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + for ($j = 0; $j < 3; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $message = "MSG_BIBLIO_IN"; + break; + } + + if ($result_max != null) + $max = $_SESSION['db']->fetch_single($result_max); + else + $max = 0; + $ret = "
"; + $ret.=""; + $ret.="
"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + if (getConstVar("ACNP_ENABLED") & getConstVar("SBN_ENABLED")) { + if ($tipo == getConstVar("ELENCO_ACNP") || $tipo == getConstVar("ELENCO_SBN") || $tipo == getConstVar("ELENCO_TUTTE") || $tipo == getConstVar("ELENCO_FUORI")) { + $ret.=getConstVar('RICERCA_NOME_BIB_LABEL') . " "; + $ret.="" . getConstVar('SEARCH') . ""; + } + } + + if ($tipo == getConstVar("ELENCO_ACNP") && getConstVar("ACNP_ENABLED")) { + if ($_SESSION['optionCons']) + $ret.=""; + else + $ret.=""; + } + + $ret.="
\n"; + $ret.=$this->navigation_bar($start, $max, $passo); + $ret.="
"; + $ret.=""; + $ret.=""; + $ret.=""; + + $arrayLength = count($flds); + + for ($j = 0; $j < $arrayLength; $j++) { + if ($flds[$j] == getConstVar("CATALOGHI")) + $ret.="\n"; + else + if ($flds[$j] == $order) { + if ($qualif == "asc") + $ret.="\n"; + else + $ret.="\n"; + } else + $ret.="\n"; + } + $rowspan = 1 + $passo; + $ret.="\n"; + + if ($_SESSION['db']->numrows($result) == 0) { + $arrayLength++; + $ret.=""; + $ret.=""; + $ret.=""; + } else { + $k = 0; + $queryCatxTUTTE = "SELECT ca_nome FROM catalogo WHERE ca_id IN (SELECT ca_id FROM biblio_catalogo WHERE bi_id = ?)"; + $listaCatSTMT = $_SESSION['db']->prepareSTMT($queryCatxTUTTE); + + if (getConstVar("ACNP_ENABLED")) { + $queryCodACNP = "SELECT acnp_cod FROM tab_acnp WHERE bi_id = ?"; + $listaCodACNP = $_SESSION['db']->prepareSTMT($queryCodACNP); + } + + while ($row = $_SESSION['db']->fetch($result)) { + $date_sospensione = array('bi_sospini' => $row['bi_sospini'], 'bi_sospfine' => $row['bi_sospfine']); + $tmp_date = getdate(strtotime($date_sospensione['bi_sospini'])); + $date_presospini = date('Y-m-d', mktime(0, 0, 0, $tmp_date['mon'], ($tmp_date['mday'] - $row['bi_preavvisososp']), $tmp_date['year'])); + $itemcl = "item1"; + if ($k % 2 != 0) + $itemcl = "item2"; + $ddnome = SQL_unescape($row[$flds[0]]); + + $ret.="\n"; + + if ($tipo != getConstVar("ELENCO_FUORI")) + $params = "onclick=\"save_collocazione(" . $row["bi_id"] . ")\""; + else + $params = ""; + + $ret.=""; + $ret.=""; + if ($tipo == getConstVar("ELENCO_ACNP")) { + $ret.=" "; + $ret.=" + "; + } elseif ($tipo == getConstVar("ELENCO_SBN")) { + $ret.=" "; + $ret.=" + "; + } elseif ($tipo == getConstVar("ELENCO_MAI")) { + $ret.=" + "; + } elseif ($tipo == getConstVar("ELENCO_ALTRO")) { + $ret.=" "; + } + if ($tipo != getConstVar("ELENCO_TUTTE") && $tipo != getConstVar("ELENCO_FUORI") && $tipo != getConstVar("ELENCO_ALTRO") && $tipo != getConstVar("ELENCO_MAI") && $tipo != getConstVar("ELENCO_SBN") && $tipo != getConstVar("ELENCO_ACNP")) { + $ret.=" "; + $ret.=" "; + $ret.=""; + } + if ($tipo == getConstVar("ELENCO_TUTTE")) { + $listaCatSTMT->bind_param('i', $row['bi_id']); + $listaCatSTMT->execute(); + $listaCatSTMT->bind_result($catalogo_name); + $cat = ""; + while ($listaCatSTMT->fetch()) { + $cat.=$catalogo_name . ", "; + } + $listaCatSTMT->free_result(); + $cat = substr($cat, 0, -2); + $ret.=""; + $ret.=""; + $ret.=""; + } + $k++; + } + $listaCatSTMT->close(); + + if (getConstVar("ACNP_ENABLED")) + $listaCodACNP->close(); + } + + $ret.="
" . $flds[$j] . "" . getConstVar($flds[$j] . "_LISTBIB_TITLE") . "" . getConstVar($flds[$j] . "_LISTBIB_TITLE") . "" . getConstVar($flds[$j] . "_LISTBIB_TITLE") . "
" . getConstVar("NOBIBLIO") . "
"; + if ($row["bi_id"] != $bi_idrichie) { + if (checkSospensioneDD(date('Y-m-d'), $date_sospensione)) { + $ret.="
" . getConstVar("LABEL_SOSP_SERVIZIO") . "
" . strtolower(getConstVar('DAL')) . " " . print_date($date_sospensione['bi_sospini']) . " " . strtolower(getConstVar('AL')) . " " . print_date($date_sospensione['bi_sospfine']) . "
"; + } else if (checkSospensioneDD(date('Y-m-d'), array('bi_sospini' => $date_presospini, 'bi_sospfine' => $row['bi_sospfine']))) { + $ret.="
" . getConstVar("LABEL_SOSP_SERVIZIO") . "
" . strtolower(getConstVar('DAL')) . " " . print_date($date_sospensione['bi_sospini']) . " " . strtolower(getConstVar('AL')) . " " . print_date($date_sospensione['bi_sospfine']) . "
"; + $ret.=""; + } else { + if ($this->preselbib == $row["bi_id"]) + $checked = "checked=checked"; + else + $checked = ""; + $ret.=""; + } + }else { + $ret.=""; + } + + $ret.="
"; + $codACNP = ""; + if (getConstVar("ACNP_ENABLED")) { + $listaCodACNP->bind_param('i', $row['bi_id']); + $listaCodACNP->execute(); + $listaCodACNP->bind_result($codACNP); + $listaCodACNP->fetch(); + $listaCodACNP->free_result(); + } + + $idbibpopup = $row['bi_id']; + if ($codACNP) + $ret.="
" . "$codACNP - " . "" . $ddnome . ""; + else + $ret.="
" . "" . $ddnome . ""; + $ret.='
'; + if ($tipo == getConstVar("ELENCO_ACNP")) { + $ix = $arrayResultACNP != null ? array_search(strtoupper($row[$flds[1]]), $arrayResultACNP['codeBibACNP']) : null; + $poss_elettronico = null; + for ($i = 0, $size = sizeof($arrayResultACNP['poss']['co'][$ix]); $i < $size; $i++) { + $collocazione_co = isset($arrayResultACNP['collocazione']['co'][$ix][$i]) == true ? $arrayResultACNP['collocazione']['co'][$ix][$i] : null; + $lacune_co = isset($arrayResultACNP['gaps']['co'][$ix][$i]) == true ? $arrayResultACNP['gaps']['co'][$ix][$i] : null; + $note_co = isset($arrayResultACNP['note']['co'][$ix][$i]) == true ? $arrayResultACNP['note']['co'][$ix][$i] : null; + $embargo_co = isset($arrayResultACNP['embargo']['co'][$ix][$i]) == true ? $arrayResultACNP['embargo']['co'][$ix][$i] : null; + $detail_co = isset($arrayResultACNP['detail']['co'][$ix][$i]) == true ? $arrayResultACNP['detail']['co'][$ix][$i] : null; + $record_co = isset($arrayResultACNP['record']['co'][$ix][$i]) == true ? $arrayResultACNP['record']['co'][$ix][$i] : null; + if ($record_co != "") + $record_co = "   [$record_co]"; + $poss_elettronico.="@: " . $arrayResultACNP['poss']['co'][$ix][$i] . $detail_co . $lacune_co . $note_co . $embargo_co . $collocazione_co . $record_co . '
'; + } + $poss_cartaceo = null; + for ($i = 0, $size = sizeof($arrayResultACNP['poss']['tx'][$ix]); $i < $size; $i++) { + if (isset($arrayResultACNP['collocazione']['tx'][$ix][$i])) { + $collocazione_tx = $arrayResultACNP['collocazione']['tx'][$ix][$i]; + $havePoss = false; + if (isset($this->ri_anno) && $this->ri_anno != 0) { + $possArray = preg_split('/(\d\d\d\d-\d\d\d\d[;,.])|(\d\d\d\d[;,.,-])/', $arrayResultACNP['poss']['tx'][$ix][$i], null, 3); + foreach ($possArray as $yearString) { + $from = null; + $to = null; + $yearString = trim($yearString, '.,;'); + if (substr($yearString, -1) == '-') { + $checkYear = preg_split('/-/', $yearString, null, 3); + $from = $checkYear[0]; + $to = date('Y'); + } else { + $checkYear = preg_split('/-/', $yearString, null, 3); + if (count($checkYear) == 2) { + $from = $checkYear[0]; + $to = $checkYear[1]; + } else { + $from = $to = $checkYear[0]; + } + } + if ($from <= $this->ri_anno && $this->ri_anno <= $to) { + $havePoss = true; + break; + } + } + } else { + $havePoss = true; + } + if ($havePoss) + $collocazione_tx = ' ' . getConstVar('COLL_COLLOCAZIONE') . ': ' . $collocazione_tx . ""; + else + $collocazione_tx = ' ' . getConstVar('COLL_COLLOCAZIONE') . ': ' . $collocazione_tx; + } else + $collocazione_tx = null; + + $lacune_tx = isset($arrayResultACNP['gaps']['tx'][$ix][$i]) == true ? $arrayResultACNP['gaps']['tx'][$ix][$i] : null; + $note_tx = isset($arrayResultACNP['note']['tx'][$ix][$i]) == true ? $arrayResultACNP['note']['tx'][$ix][$i] : null; + $embargo_tx = isset($arrayResultACNP['embargo']['tx'][$ix][$i]) == true ? $arrayResultACNP['embargo']['tx'][$ix][$i] : null; + $detail_tx = isset($arrayResultACNP['detail']['tx'][$ix][$i]) == true ? $arrayResultACNP['detail']['tx'][$ix][$i] : null; + $record_tx = isset($arrayResultACNP['record']['tx'][$ix][$i]) == true ? $arrayResultACNP['record']['tx'][$ix][$i] : null; + + if ($record_tx != "") + $record_tx = "   [$record_tx]"; + $poss_cartaceo.="print: " . $arrayResultACNP['poss']['tx'][$ix][$i] . $detail_tx . $lacune_tx . $note_tx . $embargo_tx . $collocazione_tx . $record_tx . '
'; + } + $ret.="
$poss_elettronico" . "$poss_cartaceo
"; + } + + if ($tipo == getConstVar("ELENCO_ALTRO") || $tipo == getConstVar("ELENCO_MAI")) + $ret.=" "; + + if ($tipo == getConstVar("ELENCO_SBN")) { + $ixx = $arrayResultSBN != null ? array_search(strtoupper($row[$flds[1]]), $arrayResultSBN['codeBibSBN']) : null; + if (isset($arrayResultSBN['poss'][$ixx])) + $ret.="
" . getConstVar('COLL_POSSEDUTO') . ": " . $arrayResultSBN['poss'][$ixx] . "
"; + } + $ret.="
"; + $ret.="
" . $row[$flds[1]] . "
"; + $ret.="
" . $row[$flds[2]] . "
"; + $ret.="
" . $row[$flds[1]] . "
"; + $ret.="
" . $row["sbn_cod_polo"] . "
"; + $ret.="
" . $row[$flds[2]] . "
" . $row[$flds[1]] . "
" . $row[$flds[1]] . "
" . $row[$flds[1]] . "" . $row[$flds[2]] . "
" . "$cat" . "" . $row[$flds[2]] . "
+
+ "; + + $this->controllo["bi_idforni"]["obbligo"] = 1; + $this->controllo["bi_idforni"]["tipo"] = "int"; + return $ret; + } + + public function range_filter($passo) { + $action = "onchange=\"javascript:update_list_by_range('action_borrowing.php?op=aggiorna&start=0')\""; + $passi["5"] = "5"; + $passi["10"] = "10"; + $passi["20"] = "20"; + $passi["100"] = "100"; + $passi["200"] = "200"; + $passi["300"] = "300"; + $ret = getConstVar("DISPLAY_FILTER"); + $ret.=Form::getSelect("passo", FALSE, $passi, $passo, null, "class=\"range_select\" $action", " ", "\n"); + $ret.=" " . getConstVar("AT_A_TIME") . " \n"; + return $ret; + } + + public function navigation_bar($start, $max, $passo) { + $url = "javascript:update_list('action_borrowing.php?op=aggiorna"; + if ($_SESSION['nomeFiltroBiblioteca']) { + $url.="&nomeFiltroBiblioteca=" . $_SESSION['nomeFiltroBiblioteca']; + } + $prev = ""; + $first = ""; + $last = ""; + $next = ""; + $intervall = ""; + + $ret = "
\n"; + + if ($max != 0) { + if ($start + $passo < $max) { + $pos = $start + $passo; + $intervall = ($start + 1) . " - $pos " . getConstVar("OF") . " $max\n"; + + $next = $url . "&start=" . $pos . "')"; + if ($max % $passo == 0) + $last = $max - $passo; + else + $last = $max - ($max % $passo); + $last = $url . "&start=" . $last . "')"; + + $ret.=" \">>\"\n"; + $ret.=" \">\"\n"; + $ret.="
\n"; + $ret.=" $intervall\n"; + $ret.="
\n"; + } + else { + $intervall = ($start + 1) . " - $max " . getConstVar("OF") . " $max\n"; + $ret.="
\n"; + $ret.=" $intervall\n"; + $ret.="
\n"; + } + + if ($start > 0) { + $first = $url . "&start=0')"; + $pre = $start - $passo; + $prev = $url . "&start=" . $pre . "')"; + $ret.=" \"<\"\n"; + $ret.=" \"<<\"\n"; + } else { + } + } + + + $ret.="
\n"; + + return $ret; + } + + public function preseleziona_biblioteca($bib_presel) { + $result = $_SESSION['db']->execute( + "SELECT bi_nome + FROM biblio + WHERE bi_id = $bib_presel" + ); + + $nomeforni = $_SESSION['db']->fetch_single($result); + + $ret = "
"; + $ret.= $this->richieste_settimanali($bib_presel, getConstVar("ELENCO_ACNP")); + $ret.="
"; + $ret.="
"; + + return $ret; + } + + public function richieste_settimanali($bi_idforni, $tipo) { + $nomefornires = $_SESSION['db']->execute( + "SELECT bi_nome,bi_condforni,bi_costo_dd,bi_scompenso + FROM biblio + WHERE bi_id =$bi_idforni" + ); + $condforni = ""; + $scompenso = 0; + $costoart = 0; + $diffart = 0; + $res_diff = $_SESSION['db']->execute("SELECT SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_ariel)+SUM(re_evaso_bw_altro) AS art_ricevuti,SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro) AS art_forniti,(SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro))-(SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_ariel)+SUM(re_evaso_bw_altro)) AS diff_forni_ricev FROM report_biblio as rb WHERE rb.bi_idforni =$bi_idforni AND rb.bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno=YEAR(NOW()) GROUP BY rb.bi_idforni"); + if ($res_diff && $_SESSION['db']->numrows($res_diff) == 1) { + $row = $_SESSION["db"]->fetch_row($res_diff, 0); + $diffart = $row["diff_forni_ricev"]; + } + + if ($_SESSION['db']->numrows($nomefornires) == 1) { + $dati = $_SESSION['db']->fetch_row($nomefornires, 0); + $nomeforni = SQL_unescape($dati["bi_nome"]); + $condforni = SQL_unescape($dati["bi_condforni"]); + $scompenso = $dati["bi_scompenso"]; + $costoart = $dati["bi_costo_dd"]; + } + $ret = ""; + $ret.="
"; + $result_contatore = $_SESSION['db']->execute( + "SELECT cr_richieste + FROM contarich + WHERE bi_idrichie =\"" . $this->borr_dd["bi_idrichie"]->value . "\" AND bi_idforni =" . $bi_idforni + ); + + if (!$_SESSION['db']->numrows($result_contatore)) { + $numero_richieste = 0; + $this->primaricsett = TRUE; + } else { + $numero_richieste = $_SESSION['db']->fetch_single($result_contatore); + $this->primaricsett = FALSE; + } + + if ($numero_richieste == 0) + $color = "grey"; + + else { + $color = "red"; + for ($i = 1; $i <= $numero_richieste; $i++) { + if ($i < getConstVar("QUOTA_RIC_SETT")) + $num = $i; + else + $num = "n"; + $ret.="
"; + if ($num == "n") + break; + } + + $ret.="
"; + + if ($numero_richieste >= getConstVar("QUOTA_RIC_SETT")) + $ret.=" " . getConstVar("WARNING") . "! "; + } + + $ret.=" " . getConstVar("NUM_RICHIESTE_PRE") . " " . $numero_richieste . " " . getConstVar("NUM_RICHIESTE_POST"); + $ret.="
"; + + if (getConstVar("ACNP_ENABLED")) { + $codACNP = $_SESSION['db']->execute( + "SELECT acnp_cod + FROM tab_acnp + WHERE bi_id =$bi_idforni" + ); + if ($_SESSION['db']->numrows($codACNP)) { + $cod = $_SESSION['db']->fetch_single($codACNP); + } + } + $ret.="
"; + + $ret.="
+ " . getConstVar("SCOMPENSO_PRE") . " " . $costoart . " " . getConstVar("SCOMPENSO_POST"); + $ret.="
" . getConstVar("bi_scompenso") . ""; + $ret.=" : "; + $ret.=" $scompenso"; + $ret.="
"; + $ret.="
"; + $ret.=" " . getConstVar("REPORTS_DIFF_ARTICOLI") . ""; + $ret.=" : "; + $ret.=" $diffart"; + $ret.="
"; + $ret.="

"; + + if (isset($cod) && getConstVar("ACNP_ENABLED") && ($tipo == getConstVar("ELENCO_ACNP") || $tipo == getConstVar("ELENCO_TUTTE") )) { + $ret.="
+ " . getConstVar("BIBLIO_PAGINA_ACNP") . " +
+ "; + } else { + if ($condforni != "") { + $ret.="
"; + $ret.=" " . getConstVar("bi_condforni") . ""; + $ret.=" : "; + $ret.=" $condforni"; + $ret.="
"; + } + } + return $ret; + } + + public function aggiorna_contatore_sett() { + + + if ($this->primaricsett) + $query = ( + "INSERT INTO contarich + (bi_idrichie, bi_idforni) + VALUES + (" . $this->borr_dd["bi_idrichie"]->value . ", " . $this->borr_dd["bi_idforni"]->value . ")" . " + ON DUPLICATE KEY UPDATE cr_richieste=cr_richieste" + ); + else + $query = ( + "UPDATE contarich + SET cr_richieste=cr_richieste+1 + WHERE bi_idrichie=" . $this->borr_dd["bi_idrichie"]->value . " + AND bi_idforni=" . $this->borr_dd["bi_idforni"]->value + ); + + return $_SESSION['db']->execute($query); + } + + public function set_data_annullamento() { + return $_SESSION['db']->execute("UPDATE docdel SET data_richie_annullamento=NOW() WHERE dd_id=$this->dd_id"); + } + + // DIADOSIS TEAM Added the following in order to create the first page from the scanned pdf in borrowing mode... + public function addCopyRightPage($bi_id) { + $file = getConstVar("UPLOAD_DIR") . $this->borr_dd["dd_file"]->value; + $pathinfo = pathinfo($file); + + $filecopyright = getConstVar("UPLOAD_DIR") . $pathinfo["filename"] . "_copyright.pdf"; + + $res_richie = $_SESSION['db']->execute("SELECT bi_nome FROM biblio WHERE bi_id =" . $bi_id); + $richie_row = $_SESSION['db']->fetch($res_richie); + $richie = SQL_unescape($richie_row["bi_nome"]); + $res_forni = $_SESSION['db']->execute("SELECT bi_nome FROM biblio WHERE bi_id =" . $bi_id); + $forni_row = $_SESSION['db']->fetch($res_forni); + $forni = SQL_unescape($forni_row["bi_nome"]); + + $autori = isset($this->rif["ri_au1"]) ? $this->rif["ri_au1"]->value : null; + if ($this->rif["ri_au2"]->value != "") { + if ($autori != "") + $autori.=","; + $autori.=$this->rif["ri_au2"]->value; + } + $licenza = null; + //DIADOSIS TEAM Changes to the copyright page + $result_hc = $_SESSION['db']->execute("SELECT DISTINCT u.ut_nome, u.ut_cognome, d.dip_nome FROM dipartimento d, utente u WHERE d.bi_id = " . $this->borr_dd["bi_idrichie"]->value . " AND u.ut_id = " . $this->borr_dd["ut_id"]->value . " AND u.ut_dip = d.dip_id"); + if ($result_hc && $_SESSION['db']->numrows($result_hc) == 1) { + $dati_hc = $_SESSION['db']->fetch($result_hc); + } + $data = array("TIPOMATERIALE" => isset($this->rif["ri_tipomateriale"]) ? $this->rif["ri_tipomateriale"]->value : 1, + "COPYPAGE_TEXT" => getConstVar("COPYPAGE_TEXT"), + "RICHIEDENTE" => $dati_hc["ut_nome"] . " " . $dati_hc["ut_cognome"] . " " . $dati_hc["dip_nome"], + "FORNITRICE" => $forni, + "DATARICHIE" => print_datetime($this->borr_dd["rm_datarichie"]->value), + "DATAEVA" => print_datetime($this->borr_dd["dd_lastmodify"]->value), + "TITOLO" => isset($this->rif["ri_titolopub"]) ? SQL_unescape($this->rif["ri_titolopub"]->value) : null, + "TITOLOPART" => isset($this->rif["ri_titolopart"]) ? SQL_unescape($this->rif["ri_titolopart"]->value) : null, + "AUTORI" => SQL_unescape($autori), + "ISSN" => isset($this->rif["ri_issn"]) ? $this->rif["ri_issn"]->value : null, + "ISBN" => isset($this->rif["ri_isbn"]) ? $this->rif["ri_isbn"]->value : null, + "DOI" => isset($this->rif["ri_doi"]) ? $this->rif["ri_doi"]->value : null, + "ANNO" => isset($this->rif["ri_anno"]) ? $this->rif["ri_anno"]->value : null, + "VOLUME" => isset($this->rif["ri_vol"]) ? $this->rif["ri_vol"]->value : null, + "FASCICOLO" => isset($this->rif["ri_fasc"]) ? $this->rif["ri_fasc"]->value : null, + "PGINI" => isset($this->rif["ri_pgini"]) ? $this->rif["ri_pgini"]->value : null, + "PGFINE" => isset($this->rif["ri_pgfine"]) ? $this->rif["ri_pgfine"]->value : null, + "EDITORE" => isset($this->rif["ri_editore"]) ? SQL_unescape($this->rif["ri_editore"]->value) : null, + "LICENZA" => $licenza, + "LABEL_RICHIE" => getConstVar("bi_idrichie"), + "LABEL_FORNI" => getConstVar("bi_idforni"), + "LABEL_DATARICHIE" => getConstVar("dd_datarichie"), + "LABEL_DATAEVA" => getConstVar("dd_dataeva"), + "LABEL_TITOLO" => getConstVar("ri_titolopub"), + "LABEL_TITOLOPART" => getConstVar("ri_titolopart"), + "LABEL_AUTORI" => getConstVar("ri_au1"), + "LABEL_ISSN" => getConstVar("ri_issn"), + "LABEL_ISBN" => getConstVar("ri_isbn"), + "LABEL_DOI" => getConstVar("ri_doi"), + "LABEL_ANNO" => getConstVar("ri_anno"), + "LABEL_VOLUME" => getConstVar("ri_vol"), + "LABEL_FASCICOLO" => getConstVar("ri_fasc"), + "LABEL_PGINI" => getConstVar("ri_pgini"), + "LABEL_PGFINE" => getConstVar("ri_pgfine"), + "LABEL_EDITORE" => getConstVar("ri_editore"), + "LABEL_LICENZA" => getConstVar("CONTRATTO") + ); + $copyright = new Copyright($data); + $copyright->setInputDirectory(getConstVar("UPLOAD_DIR")); + $copyright->setOutputPdfFilename($filecopyright); + if ($copyright->generatePDFPage()) { + if (!file_exists($filecopyright)) + return false; + } + return true; + } + +} + +?> diff --git a/modules/controllo_campi.php b/modules/controllo_campi.php new file mode 100755 index 0000000..d0781ba --- /dev/null +++ b/modules/controllo_campi.php @@ -0,0 +1,298 @@ + $v) { + if (strpos($key, "_file")) { + if (isset($controllo[$key]) && $controllo[$key]["obbligo"] == 1 && isset($post[$key . "_full"]) && $post[$key . "_full"] != 1) + $error[$key] = $key; + } + else + if (isset($controllo[$key]) && $controllo[$key]["obbligo"] == 1 && (!isset($post[$key]) || $post[$key] == "")) { + $error[$key] = $key; + } + } + + if (isset($controllo["bi_piva"]) && empty($post["bi_piva"]) && empty($post["bi_cf"])) { + $error["bi_piva"] = "bi_piva"; + $error["bi_cf"] = "bi_cf"; + } + + $data1 = null; + $data2 = null; + + if (isset($controllo["bi_sospini_gg"]) || isset($controllo["bi_sospini_mm"]) || isset($controllo["bi_sospini_aaaa"])) + $data1 = $post["bi_sospini_gg"] . $post["bi_sospini_mm"] . $post["bi_sospini_aaaa"]; + + if (isset($controllo["bi_sospfine_gg"]) || isset($controllo["bi_sospfine_mm"]) || isset($controllo["bi_sospfine_aaaa"])) + $data2 = $post["bi_sospfine_gg"] . $post["bi_sospfine_mm"] . $post["bi_sospfine_aaaa"]; + + if ($data1 == null && $data2 != null) { + $error["bi_sospini_gg"] = "bi_sospini_gg"; + $error["bi_sospini_mm"] = "bi_sospini_mm"; + $error["bi_sospini_aaaa"] = "bi_sospini_aaaa"; + } + if ($data2 == null && $data1 != null) { + $error["bi_sospfine_gg"] = "bi_sospfine_gg"; + $error["bi_sospfine_mm"] = "bi_sospfine_mm"; + $error["bi_sospfine_aaaa"] = "bi_sospfine_aaaa"; + } + return $error; + } + + private function coerenza(&$post, &$controllo) { + $error = null; + foreach ($controllo as $key => $v) { + if (isset($controllo[$key]["tipo"])) { + switch ($controllo[$key]["tipo"]) { + + case "int": + if (!empty($post[$key]) && !ctype_digit($post[$key])) + $error[$key] = $key; + else if (isset($post[$key])) + $post[$key] = (int) $post[$key]; + break; + + case "decimal": + $post[$key] = str_replace(',', '.', $post[$key]); + if (!empty($post[$key]) && !preg_match("/^[0-9]{1,5}([\.][0-9][0-9]?)?$/i", $post[$key])) + $error[$key] = $key; + if (!empty($post[$key]) && preg_match("/^[0-9]{1,5}[\.][0-9]$/i", $post[$key])) + $post[$key] = $post[$key] . "0"; + elseif (!empty($post[$key]) && preg_match("/^[0-9]{1,5}$/i", $post[$key])) + $post[$key] = $post[$key] . ".00"; + break; + } + } + } + + return $error; + } + + + private static function forma(&$post, &$controllo) { + $error = null; + foreach ($controllo as $key => $v) { + + if (strpos($key, "email") && !empty($post[$key]) && !preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", $post[$key])) { + $error[$key] = $key; + } + if (strpos($key, "url") && !empty($post[$key]) && !preg_match("/^(http:\/\/|https:\/\/)[:\/~a-zA-Z0-9_\-\.\?#=&]+$/i", $post[$key])) { + $post[$key] = "http://" . $post[$key]; + } + if (strpos($key, "_file") && !empty($post[$key]) && !preg_match("/^(file:\/\/)[:\/~a-zA-Z0-9_\-\.\?#=&]+$/", $post[$key])) { + $post[$key] = "file://" . $post[$key]; + } + if (strpos($key, "issn") && !empty($post[$key])) { + if (preg_match("/[0-9]{7}[0-9X]{1}$/i", $post[$key])) { + $trunk = str_split($post[$key], 4); + $post[$key] = $trunk[0] . "-" . $trunk[1]; + } + if (!preg_match("/[0-9]{4}[-]?[0-9]{3}[0-9X]{1}$/i", $post[$key])) { + $error[$key] = $key; + } + } + if ((strpos($key, "_tel") || strpos($key, "_fax") ) && !empty($post[$key]) && !preg_match("/^[+0-9]+$/i", $post[$key])) { + $error[$key] = $key; + } + if ($key == 'ri_anno' && !empty($post[$key]) && $post[$key] > (date('Y') + 1)) { + $error[$key] = $key; + } + + } + return $error; + } + + public static function check_richiesta(&$post, $tipomat) { + if ($tipomat == getConstVar("TIPO_ARTICOLO")) { + + if( + (!empty($post["ri_anno"]) && !empty($post["ri_pgini"])) || + (!empty($post["ri_anno"]) && !empty($post["ri_au1"])) || + (!empty($post["ri_vol"]) && !empty($post["ri_pgini"])) || + (!empty($post["ri_vol"]) && !empty($post["ri_au1"])) + + ) + return false; + } + elseif ($tipomat == getConstVar("TIPO_LIBRO")) { + if( + (!empty($post["ri_anno"]) && !empty($post["ri_pgini"]) && !empty($post["ri_pgfine"])) || + (!empty($post["ri_anno"]) && !empty($post["ri_au1"])) + + ) + return false; + } + return true; + } + + public static function check_username(&$post, &$controllo) { + $error = null; + + if (isset($controllo["ut_usr"])) + $tab = "ut"; + elseif (isset($controllo["bi_usr"])) + $tab = "bi"; + else + return NULL; + + + + $res_ute = $_SESSION['db']->execute("SELECT COUNT(ut_id) FROM utente WHERE ut_usr='" . $post[$tab . "_usr"] . "'"); + if ($res_ute) + if ($_SESSION['db']->fetch_single($res_ute) >= 1) + $error[$tab . "_usr"] = $tab . "_usr"; + else { + $res_bib = $_SESSION['db']->execute("SELECT COUNT(bi_id) FROM biblio WHERE bi_usr='" . $post[$tab . "_usr"] . "'"); + if ($res_bib) + if ($_SESSION['db']->fetch_single($res_bib) >= 1) + $error[$tab . "_usr"] = $tab . "_usr"; + else if (strlen($post[$tab . "_usr"]) < getConstVar("USR_MINLENGTH")) + $error[$tab . "_usr"] = $tab . "_usr"; + } + return $error; + } + + public static function check_password(&$post, &$controllo) { + $error = null; + + if (isset($controllo["ut_pwd"])) + $tab = "ut"; + elseif (isset($controllo["bi_pwd"])) + $tab = "bi"; + else + return NULL; + + if (!empty($post[$tab . "_pwd"]) && empty($post[$tab . "_pwd_2"])) + $error[$tab . "_pwd_2"] = $tab . "_pwd_2"; + elseif (empty($post[$tab . "_pwd"]) && !empty($post[$tab . "_pwd_2"])) + $error[$tab . "_pwd"] = $tab . "_pwd"; + elseif (!empty($post[$tab . "_pwd"]) && !empty($post[$tab . "_pwd_2"]) && $post[$tab . "_pwd"] != $post[$tab . "_pwd_2"]) + $error[$tab . "_pwd_2"] = $tab . "_pwd_2"; + elseif (!empty($post[$tab . "_pwd"]) && !empty($post[$tab . "_pwd_2"]) && $post[$tab . "_pwd"] == $post[$tab . "_pwd_2"] && strlen($post[$tab . "_pwd"]) < getConstVar("PWD_MINLENGTH")) { + $error[$tab . "_pwd"] = $tab . "_pwd"; + $error[$tab . "_pwd_2"] = $tab . "_pwd_2"; + } + return $error; + } + + public static function check_date($post, $data, $yearfrom = null, $yearto = null) { + $error = null; + + if (!isset($yearto) || $yearto == null) + $yearto = date('Y') + 1; + if (!isset($yearfrom) || $yearfrom == null) + $yearfrom = date('Y') - 1; + + + + if (($post[$data . "_mm"] != "") && ($post[$data . "_gg"] != "") && ($post[$data . "_aaaa"] != "")) { + if ($post[$data . "_aaaa"] >= $yearfrom && $post[$data . "_aaaa"] <= $yearto) { + + if (!checkdate($post[$data . "_mm"], $post[$data . "_gg"], $post[$data . "_aaaa"])) { + $error[$data . "_gg"] = $data . "_gg"; + $error[$data . "_mm"] = $data . "_mm"; + $error[$data . "_aaaa"] = $data . "_aaaa"; + } + } else + $error[$data . "_aaaa"] = $data . "_aaaa"; + } + else { + if (($post[$data . "_mm"] == "") && ($post[$data . "_gg"] == "") && ($post[$data . "_aaaa"] == "")) + return null; + else { + if ($post[$data . "_mm"] == "") + $error[$data . "_mm"] = $data . "_mm"; + if ($post[$data . "_gg"] == "") + $error[$data . "_gg"] = $data . "_gg"; + if ($post[$data . "_aaaa"] == "") + $error[$data . "_aaaa"] = $data . "_aaaa"; + } + } + + return $error; + } + + public static function check_dataeva($dataeva, $dataric) { + $error = null; + + $timestamp_dataric = strtotime($dataric); + $timestamp_dataeva = strtotime($dataeva); + + $datadif = $timestamp_dataric - $timestamp_dataeva; + + if ($datadif > 86400) { + $error["dd_dataeva_gg"] = 'dd_dataeva_gg'; + $error["dd_dataeva_mm"] = 'dd_dataeva_mm'; + $error["dd_dataeva_aaaa"] = 'dd_dataeva_aaaa'; + } elseif ((0 < $datadif) && ($datadif < 86400)) { + $timestamp_dataeva = $timestamp_dataric + 1; + $dataeva = date('Y-m-d H:i:s', $timestamp_dataeva); + } + return $error; + } + + public static function check_sospensione_dd(&$post, &$controllo) { + $error = null; + if (isset($controllo["bi_sospini_gg"]) && isset($controllo["bi_sospfine_gg"]) && $post["bi_sospini_gg"] != "" && $post["bi_sospfine_gg"] != "") { + + $t_sospini = strtotime($post["bi_sospini_aaaa"] . "-" . $post["bi_sospini_mm"] . "-" . $post["bi_sospini_gg"]); + $t_sospfine = strtotime($post["bi_sospfine_aaaa"] . "-" . $post["bi_sospfine_mm"] . "-" . $post["bi_sospfine_gg"]); + $t_now = strtotime(date("Y-m-d")); + + + if ($t_sospini > $t_sospfine) { + $error["bi_sospini_gg"] = "bi_sospini_gg"; + $error["bi_sospini_mm"] = "bi_sospini_mm"; + $error["bi_sospini_aaaa"] = "bi_sospini_aaaa"; + + $error["bi_sospfine_gg"] = "bi_sospfine_gg"; + $error["bi_sospfine_mm"] = "bi_sospfine_mm"; + $error["bi_sospfine_aaaa"] = "bi_sospfine_aaaa"; + } + + if ($t_sospini < $t_now) { + $error["bi_sospini_gg"] = "bi_sospini_gg"; + $error["bi_sospini_mm"] = "bi_sospini_mm"; + $error["bi_sospini_aaaa"] = "bi_sospini_aaaa"; + } + + if ($t_sospfine < $t_now) { + $error["bi_sospfine_gg"] = "bi_sospfine_gg"; + $error["bi_sospfine_mm"] = "bi_sospfine_mm"; + $error["bi_sospfine_aaaa"] = "bi_sospfine_aaaa"; + } + } + + return $error; + } + +} + +?> diff --git a/modules/fieldrender.php b/modules/fieldrender.php new file mode 100755 index 0000000..c841971 --- /dev/null +++ b/modules/fieldrender.php @@ -0,0 +1,134 @@ +type) ? $fieldobj->type : null; + $name = isset($fieldobj->fieldname) ? $fieldobj->fieldname : null; + $val = ""; + + if ((strpos($name, "_id") && ($name != "dd_id")) || ($name == 'ut_dip')) { + $val = getIDValue($fieldobj); + } else { + $val = $fieldobj->value; + switch ($type) { + + case "date": + $val = print_date($val); + break; + + case "datetime": + $val = print_datetime($val, "date"); + break; + } + } + + if (!isset($segnaposto)) + $segnaposto = $name; + $s = self::render($segnaposto, $val, $extra); + + return $s; + } + + public static function render($name, $val, $extra = "") { + + global $$name; + + if ($val != "") { + $val = SQL_unescape($val); + + if (strpos($name, "_url")) { + $s = "
"; + $s.=" " . $$name . ": " . $val . ""; + $s.="$extra
"; + } else if (strpos($name, "_file")) { + $s = "
"; + $s.=" " . $$name . ": " . $val . ""; + $s.="$extra
"; + } else if (strpos($name, "_tel") || strpos($name, "_email") || strpos($name, "_fax")) { + $s = "
"; + $s.="" . $val . ""; + $s.="$extra
"; + } else if ($name == "rm_note") { + $s = "
"; + $s.=" " . $val . " "; + $s.="$extra
"; + } else if ($name == "dd_note") { + $s = "
"; + $s.=" " . $$name . ": " . $val . ""; + $s.="$extra
\n"; + } else if (strpos($name, "_stato")) { + $s = ""; + $s.=" "; +// DIADOSIS TEAM Add explanation span regarding status of a request in user's home page + switch ($val) { + case '10': + $s .= " " . getConstVar($name . $val) . ""; + break; + case '20': + $s .= " " . getConstVar($name . $val) . ""; + break; + case '30': + $s .= " " . getConstVar($name . $val) . ""; + break; + case '31': + $s .= " " . getConstVar($name . $val) . ""; + break; + default: + $s .= " " . getConstVar($name . $val) . ""; + break; + } + $s.="$extra"; + } else if (strpos($name, "_datarichie")) { + $s = "
"; + $s.=" " . $$name . ": "; + $s.=" " . print_datetime($val, "date") . " "; + $s.="$extra
\n"; + } else if (strpos($name, "_sosp")) { + $s = " " . print_datetime($val, "date") . " "; + } else if (strpos($name, "_countbib") || strpos($name, "_nprotrichie") || strpos($name, "_nproteva") || strpos($name, "_collocazione") || strpos($name, "_ninventarioforni") || (strpos($name, "_id") && $name != "qu_id" && $name != "di_id" && $name != "en_id" && $name != "pr_id" && $name != "na_id" && $name != "prov_id" && $name != "ed_id" && $name != "piatt_id" && $name != "contr_id")) { + $s = "
"; + $s.=" " . $$name . ":" . $val; + $s.="$extra
\n"; + } else if (strpos($name, "costo")) { + $s = "
"; + $s.=" " . $$name . ": "; + $s.=" " . $val . " € "; + $s.="$extra
\n"; + } else if (strpos($name, "_check")) { + $s = "
"; + $chk = ""; + if ($val == 1) + $chk = "checked=\"checked\""; + if ($val == 0) + $chk = ""; + $s.=" " . $$name . ": "; + $s.="$extra
"; + } + + + else { + $s = "
"; + $s.=" " . $$name . ": "; + $s.=" " . $val . " "; + $s.="$extra
\n"; + } + } else + if ($name == "rm_note") { + $s = "
"; + $s.=" " . getConstVar("NO_RM_NOTE") . ""; + $s.="$extra
"; + } + if (isset($s)) + return $s; + else + return null; + } + +} + +?> diff --git a/modules/form.php b/modules/form.php new file mode 100755 index 0000000..566d9f7 --- /dev/null +++ b/modules/form.php @@ -0,0 +1,389 @@ +elements = ""; + else + $this->elements.="$pre_tag
$post_tag"; + } + + static function getHidden($name, $val, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + static function getInputText($name, $val, $maxlength, $size, $extra = null, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + static function getPassword($name, $val, $maxlength, $size, $extra = null, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + static function getTextArea($name, $val, $rows = "", $cols = "", $extra = null, $pre_tag = null, $post_tag = null) { + if ($rows > 0) + $rows = "rows=\"$rows\""; + else + $rows = "rows=\"\""; + if ($cols > 0) + $cols = "cols=\"$cols\""; + else + $cols = "cols=\"\""; + + return "$pre_tag$post_tag"; + } + + static function getSelect($name, $multiple, $options, $selected_index, $size = 1, $extra = null, $pre_tag = null, $post_tag = null) { + if ($multiple) + $multiple = "multiple=\"multiple\""; + if (isset($size) && $size != "" && $size > 1) + $size = "size=\"$size\""; + else + $size = ""; + $lista = "$pre_tag$post_tag"; + return $lista; + } + + static function getSelectOptions($options, $selected_index = null) { + $lista = ""; + foreach ($options as $key => $val) { + $sel = ""; + if ($key == $selected_index && $selected_index != "" && $selected_index != null) + $sel = "selected=\"selected\""; + $lista.="\n"; + } + return $lista; + } + + static function getRadio($name, $val, $checked = FALSE, $extra = null, $pre_tag = null, $post_tag = null, $alt_id = null) { + if ($checked) + $checked = "checked=\"checked\""; + else + $checked = ""; + + if ($alt_id != "") + $id = "id=\"" . $alt_id . "\""; + else + $id = "id=\"$name\""; + return "$pre_tag$post_tag"; + } + + static function getCheckbox($name, $val, $checked = FALSE, $extra = null, $pre_tag = null, $post_tag = null) { + if ($checked) + $checked = "checked=\"checked\""; + return "$pre_tag$post_tag"; + } + + static function getFile($name, $val = null, $size = null, $extra = null, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + static function getButton($name, $val, $extra = null, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + static function getReset($name, $val, $extra = null, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + static function getSubmit($name, $val, $extra = null, $pre_tag = null, $post_tag = null) { + return "$pre_tag$post_tag"; + } + + + function addHidden($name, $val, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getHidden($name, $val, $pre_tag, $post_tag); + } + + function addInputText($name, $val, $maxlength, $size, $extra = null, $pre_tag = null, $post_tag = null) { + + $this->elements.=$this->getInputText($name, $val, $maxlength, $size, $extra, $pre_tag, $post_tag); + } + + function addPassword($name, $val, $maxlength, $size, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getPassword($name, $val, $maxlength, $size, $extra, $pre_tag, $post_tag); + } + + function addTextArea($name, $val, $rows = null, $cols = null, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getTextArea($name, $val, $rows, $cols, $extra, $pre_tag, $post_tag); + } + + function addSelect($name, $multiple, $options, $selected_index, $size = 1, $extra = null, $pre_tag = null, $post_tag = null) { + + $this->elements.=$this->getSelect($name, $multiple, $options, $selected_index, $size = 1, $extra, $pre_tag, $post_tag); + } + + function addRadio($name, $val, $checked = FALSE, $extra = null, $pre_tag = null, $post_tag = null, $alt_id = null) { + $this->elements.=$this->getRadio($name, $val, $checked, $extra, $pre_tag, $post_tag, $alt_id); + } + + function addCheckbox($name, $val, $checked = FALSE, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getCheckbox($name, $val, $checked, $extra, $pre_tag, $post_tag); + } + + function addFile($name, $val = null, $size = null, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getFile($name, $val, $size, $extra, $pre_tag, $post_tag); + } + + function addButton($name, $val, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getButton($name, $val, $extra, $pre_tag, $post_tag); + } + + function addReset($name, $val, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getReset($name, $val, $extra, $pre_tag, $post_tag); + } + + function addSubmit($name, $val, $extra = null, $pre_tag = null, $post_tag = null) { + $this->elements.=$this->getSubmit($name, $val, $extra, $pre_tag, $post_tag); + } + + function close() { + $this->elements.="
"; + } + + function addHTML($stringa) { + $this->elements.=$stringa; + } + + function stampa() { + echo $this->elements; + } + + function restituisci() { + return $this->elements; + } + + function addRadioSiNo($name, $checkSINO = FALSE, $extra = null, $pre_tag = null, $post_tag = null, $alt_id = null) { + $checkNO = FALSE; + $checkSI = FALSE; + + if ($checkSINO === 0) + $checkNO = TRUE; + else if ($checkSINO === 1) + $checkSI = TRUE; + + + $this->addHTML("
" . $$name . ":
"); + $this->addHTML(" "); + $this->addHTML(getConstVar("NO") . " "); + $this->addRadio($name . "_radio", 0, $checkNO, $extra, $pre_tag, $post_tag, $alt_id); + $this->addHTML(getConstVar("SI") . " "); + $this->addRadio($name . "_radio", 1, $checkSI, $extra, $pre_tag, $post_tag, $alt_id); + + $this->addHTML(" "); + $this->addHTML("
"); + } + +} + +; + +class FieldsForm extends Form { + + function __construct($name = null, $action = null, $extra = null) { + parent::__construct($name, $action, "POST", $extra); + } + function addField($fieldobj, $extra = null, $pre_tag = null, $post_tag = null, $forceempty = null, $forcerequired = null) { + $controllo = null; + + $type = isset($fieldobj->type) ? $fieldobj->type : null; + $name = isset($fieldobj->fieldname) ? $fieldobj->fieldname : null; + if (isset($fieldobj->value) && $fieldobj->value !== "") + $val = SQL_unescape($fieldobj->value); + else + $val = isset($fieldobj->defaultval) ? $fieldobj->defaultval : null; + $maxlength = isset($fieldobj->maxsize) ? $fieldobj->maxsize : null; + + global $$name; + if ($forceempty == 1) { + if ($type == "int" || $type == "float" || $type == "decimal") + $val = 0; + else + $val = ""; + } + $this->addHTML("
"); + + if ($name != "rm_note" && $name != "bi_condforni" && !strpos($name, "_sosp") && $name != "bi_preavvisososp") + $this->addHTML("
" . $$name . ":
"); + + if (strpos($name, "_sosp")) + $this->addHTML("
" . $$name . "
"); + + if (strpos($name, "_tel") || strpos($name, "_fax")) { + $phonearr = parse_phone($val); + $val_pre = isset($phonearr[0]) ? $phonearr[0] : null; + $val_num = isset($phonearr[1]) ? $phonearr[1] : null; + $this->addInputText($name . self::$pref, $val_pre, 6, 6, $extra, $pre_tag, ""); + + $this->addHTML(" - "); + $this->addInputText($name . self::$numero, $val_num, 12, 12, $extra, "", $post_tag); + $controllo[$name . self::$pref]["obbligo"] = (!(isset($fieldobj->isnull) ? $fieldobj->isnull : null)) || $forcerequired; + $controllo[$name . self::$pref]["tipo"] = $type; + $controllo[$name . self::$numero]["obbligo"] = (!(isset($fieldobj->isnull) ? $fieldobj->isnull : null)) || $forcerequired; + $controllo[$name . self::$numero]["tipo"] = $type; + $star = ""; + if ($controllo[$name . self::$pref]["obbligo"]) + $star = "" . getConstVar("CAMPO_OBBLIGATORIO") . ""; + } else if (($name == 'data_eva') || strpos($name, "_data") || strpos($name, "_sosp")) { + $datearr = parse_date($val); + + if ($name == 'dd_dataeva' && isset($_SESSION['dd_dataevaFN'])) { + unset($_SESSION['dd_dataevaFN']); + $val_aaaa = date('Y'); + $val_mm = date('m'); + $val_gg = date('d'); + } else { + $val_aaaa = isset($datearr[0]) ? $datearr[0] : null; + $val_mm = isset($datearr[1]) ? $datearr[1] : null; + $val_gg = isset($datearr[2]) ? $datearr[2] : null; + } + $this->addInputText($name . self::$giorno, $val_gg, 2, 2, $extra, $pre_tag, " / "); + $this->addInputText($name . self::$mese, $val_mm, 2, 2, "", "", " / "); + $this->addInputText($name . self::$anno, $val_aaaa, 4, 4, "", "", $post_tag); + $controllo[$name . self::$giorno]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name . self::$giorno]["tipo"] = $type; + $controllo[$name . self::$mese]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name . self::$mese]["tipo"] = $type; + $controllo[$name . self::$anno]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name . self::$anno]["tipo"] = $type; + if ($forcerequired == 1) { + $controllo[$name . self::$giorno]["obbligo"] = 1; + $controllo[$name . self::$mese]["obbligo"] = 1; + $controllo[$name . self::$anno]["obbligo"] = 1; + } + $star = ""; + if ($controllo[$name . self::$anno]["obbligo"]) + $star = "" . getConstVar("CAMPO_OBBLIGATORIO") . ""; + } + else { + if (strpos($name, "_pwd")) { + $this->addPassword($name, NULL, $maxlength, 30, $extra, $pre_tag, $post_tag); + $controllo[$name]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name]["tipo"] = $type; + } else if (strpos($name, "_doi")) { + $doiarr = parse_doi($val); + $val_pre = isset($doiarr[0]) ? $doiarr[0] : null; + $val_suf = isset($doiarr[1]) ? $doiarr[1] : null; + $this->addInputText($name . self::$pref, $val_pre, 6, 6, "", "10.", ""); + $this->addInputText($name . self::$suf, $val_suf, 255, 25, "", " / ", $post_tag); + $controllo[$name . self::$pref]["obbligo"] = !($fieldobj->isnull); + $controllo[$name . self::$pref]["tipo"] = $type; + $controllo[$name . self::$suf]["obbligo"] = !($fieldobj->isnull); + $controllo[$name . self::$suf]["tipo"] = $type; + } else if (strpos($name, "_file")) { + $this->addHTML("$val"); + if ($val == "") + $style = ""; + else + $style = "style=\"display:none\""; + $this->addFile($name, $val, 40, $style); + $controllo[$name]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name]["tipo"] = $type; + } + else if (strpos($name, "_check")) { + $checked = false; + if ($fieldobj->value == 1) + $checked = true; + + $fieldobj->value = 1; + $this->addFieldCheckbox($fieldobj, $checked, $extra, $pre_tag, $post_tag); + } + + else { + $controllo[$name]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name]["tipo"] = $type; + switch ($type) { + case "text": + case "blob": + $this->addTextArea($name, $val, 0, 0, $extra, $pre_tag, $post_tag); + $controllo[$name]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name]["tipo"] = $type; + break; + + case "datetime": + break; + default: + $this->addInputText($name, $val, $maxlength, 30, $extra, $pre_tag, $post_tag); + $controllo[$name]["obbligo"] = !(isset($fieldobj->isnull) ? $fieldobj->isnull : null); + $controllo[$name]["tipo"] = $type; + } + } + + if ($forcerequired == 1) + $controllo[$name]["obbligo"] = 1; + + $star = ""; + if (isset($controllo[$name]["obbligo"]) && $controllo[$name]["obbligo"]) + $star = "" . getConstVar("CAMPO_OBBLIGATORIO") . ""; + } + $this->addHTML("$star"); + $this->addHTML("
"); + + + return $controllo; + } + + function addFieldSelect($fieldobj, $multiple, $options, $size = 1, $extra = null, $pre_tag = null, $post_tag = "\n") { + $controllo = null; + $selected_index = $fieldobj->value; + $name = $fieldobj->fieldname; + + $star = ""; + if (!$fieldobj->isnull) + $star = "" . getConstVar("CAMPO_OBBLIGATORIO") . ""; + + global $$name; + if ($extra == "style=\"display: none;\"") + $this->addHTML("
" . $$name . ": " . $options[key($options)] . "
"); + else + $this->addHTML("
" . $$name . ":
"); + + $this->addSelect($name, $multiple, $options, $selected_index, $size, $extra, $pre_tag . "", "$star" . $post_tag); + $this->addHTML("
"); + $controllo[$name]["obbligo"] = !($fieldobj->isnull); + $controllo[$name]["tipo"] = $fieldobj->type; + return $controllo; + } + + function addFieldRadio($fieldobj, $checked = FALSE, $extra = null, $pre_tag = null, $post_tag = null, $alt_id = null) { + $controllo = null; + $name = $fieldobj->fieldname; + $val = $fieldobj->value; + $this->addRadio($name, $val, $checked, $extra, $pre_tag, $post_tag, $alt_id); + $controllo[$name]["obbligo"] = !($fieldobj->isnull); + $controllo[$name]["tipo"] = $fieldobj->type; + return $controllo; + } + + function addFieldCheckbox($fieldobj, $checked = FALSE, $extra = null, $pre_tag = null, $post_tag = null) { + $controllo = null; + $name = $fieldobj->fieldname; + $val = $fieldobj->value; + $this->addCheckbox($name, $val, $checked, $extra, $pre_tag, $post_tag); + $controllo[$name]["obbligo"] = !($fieldobj->isnull); + $controllo[$name]["tipo"] = $fieldobj->type; + return $controllo; + } + +} + +; +?> diff --git a/modules/hc_download_file.php b/modules/hc_download_file.php new file mode 100644 index 0000000..08027f3 --- /dev/null +++ b/modules/hc_download_file.php @@ -0,0 +1,135 @@ + $url, + CURLOPT_HTTPGET => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPAUTH => CURLAUTH_ANY, + CURLOPT_USERPWD => implode(':', $credentials), + CURLOPT_SSL_VERIFYPEER => FALSE, + CURLOPT_SSL_VERIFYHOST => 2, + CURLOPT_CAINFO => "{path to CA}", + CURLOPT_CERTINFO => TRUE + ); + curl_setopt_array($ch2, $options); + $share_info = curl_exec($ch2); + $result = simplexml_load_string($share_info); + $info2 = curl_getinfo($ch2); + $error_no2 = curl_errno($ch2); + curl_close($ch2); + + $path = $result->data->element->path; + $APP = "{URL}" . $path; + $ch3 = curl_init(); + $options = array( + CURLOPT_URL => $APP, + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPAUTH => CURLAUTH_ANY, + CURLOPT_USERPWD => implode(':', $credentials), + CURLOPT_SSL_VERIFYPEER => FALSE, + CURLOPT_SSL_VERIFYHOST => 2, + CURLOPT_CAINFO => "{path to CA}", + CURLOPT_CERTINFO => TRUE + ); + + curl_setopt_array($ch3, $options); + + $postResult3 = curl_exec($ch3); + $info3 = curl_getinfo($ch3); + $error_no3 = curl_errno($ch3); + curl_close($ch3); + fclose($f); + unlink($lock); + flush(); + exit(); + } else if ($info["content_type"] == 'text/html; charset=UTF-8' && ($info["http_code"] == '404' || $info["http_code"] == '400')) { + header('Location: https://diadosis.grnet.gr/error.php?msg=' . urlencode("Το αρχείο δεν βρέθηκε. Στην περίπτωση που το έχετε ήδη κατεβάσει έχει διαγραφεί από τον εξυπηρετητή. Θα πρέπει να επαναλάβετε το αίτημα διαδανεισμού.")); + fclose($f); + if (file_exists($lock)) + unlink($lock); + } else { + header('Location: https://diadosis.grnet.gr/error.php?msg=' . urlencode("Κάποιο πρόβλημα παρουσιάστηκε κατά το κατέβασμα. Παρακαλούμε επικοινωνήστε μαζί μας.")); + fclose($f); + if (file_exists($lock)) + unlink($lock); + } + +} else if (isset($_GET['f']) && $_GET['f'] != "") { + header("Cache-control: private, no-cache"); + header("Pragma: no-cache"); + $fname = basename(strip_tags($_GET['f'])); + $fp = fopen($fname, "r"); + if ($fp) { + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: public", FALSE); + header("Content-Description: File Transfer"); + header("Content-type: application/octet-stream"); + if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) + header('Content-Type: application/force-download'); + header("Accept-Ranges: bytes"); + header("Content-Disposition: attachment; filename=\"$fname\";"); + header("Content-Transfer-Encoding: binary"); + header("Content-Length: " . filesize($fname)); + do { + echo fread($fp, 8192); + } while (!feof($fp)); + fclose($fp); + } else + header('Location: https://diadosis.grnet.gr/error.php?msg=' . urlencode("Το αρχείο δεν βρέθηκε. Στην περίπτωση που το έχετε ήδη κατεβάσει έχει διαγραφεί από τον εξυπηρετητή. Θα πρέπει να επαναλάβετε το αίτημα διαδανεισμού.")); +} else + header('Location: https://diadosis.grnet.gr/error.php?msg=' . urlencode("Πρόβλημα στο url. Παρακαλούμε πατήστε ακριβώς ή αντιγράψτε τον σύνδεσμό που σας έχει αποσταλεί με email.")); +?> + + diff --git a/modules/hc_no_oc.php b/modules/hc_no_oc.php new file mode 100644 index 0000000..c4a76cb --- /dev/null +++ b/modules/hc_no_oc.php @@ -0,0 +1,210 @@ +dd_id > 0) { + $bibforni = new Biblio($borrow->bi_idforni); + + switch ($stato_hc) { + case (int) 0: + $borrow->dd_stato_ddill = 0; + $borrow->dd_stato_file = getConstVar("DD_STATO_FILE_DOWNLOAD_READY"); + break; + case -1: + case -2: + $borrow->dd_stato_ddill = 0; + $borrow->dd_stato_file = getConstVar("DD_STATO_FILE_NO_DOWNLOAD"); + break; + case 1: + $borrow->dd_stato_ddill = 0; + $borrow->dd_stato_file = getConstVar("DD_STATO_FILE_DOWNLOAD_HC"); + break; + + case 2: + $borrow->dd_stato_ddill = 0; + $borrow->dd_stato_file = getConstVar("DD_STATO_FILE_DOWNLOAD_WM"); + break; + } + + $borrow->dd_stato_borr = getConstVar("BORR_CONS_DIRETTA"); + $borrow->dd_file = $ddid . ".pdf"; + + $ok = $borrow->aggiornaDB(); + } else { + sendAjaxXML(501, getConstVar("ERR_LASTMODIFY_MSG"), null, null); + exit(); + } +} + +$msg = null; +$er = false; + +if (isset($_GET["recover"]) && $_GET["recover"] == 1 && isset($_GET["ddid"]) && isset($_GET["statofile"])) { + update_nilde_dd($_GET["ddid"], $_GET["statofile"]); + echo "Recovery of ID: " . $_GET["ddid"] . " successfully performed. New State: " . $_GET["statofile"]; +} else +if (isset($_POST["ddid"]) && isset($_POST["statofile"])) { + $borrow = new Borrowing($_POST["ddid"]); +} + +if ($_POST["statofile"] == 1 || $_POST["statofile"] == 2) { + $upload_folder = getConstVar("HC_UPLOAD_DIR"); +} else if ($_POST["statofile"] == 0 || $_POST["statofile"] == -2 || $_POST["statofile"] == -1) { + $upload_folder = getConstVar("UPLOAD_DIR"); +} + +if ($_POST["statofile"] == 1 || $_POST["statofile"] == 2 || $_POST["statofile"] == 0 || $_POST["statofile"] == -2 || $_POST["statofile"] == -1) { + if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { + $aaa = move_uploaded_file($_FILES['userfile'] ['tmp_name'], $upload_folder . $_POST["ddid"] . ".pdf"); + if ($aaa) { + $msg = $_POST["ddid"] . " moved to " . $upload_folder . "-> OK | "; + $filename = $upload_folder . $_POST["ddid"] . ".pdf"; + + $credentials = array( + '{username}', + '{password}' + ); + $header[] = "Content-Type: application/pdf"; + $post_fields = array('file' => '@' . $filename); + $APP = "{URL}" . $_POST["ddid"] . ".pdf"; + $ch = curl_init(); + $filesize = filesize($filename); + + $fp = fopen($filename, 'r'); + + $options = array( + CURLOPT_URL => $APP, + CURLOPT_HTTPHEADER => $header, + CURLOPT_PUT => true, + CURLOPT_POSTFIELDS => $post_fields, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_UPLOAD => true, + CURLOPT_INFILE => $fp, + CURLOPT_INFILESIZE => $filesize, + CURLOPT_HTTPAUTH => CURLAUTH_ANY, + CURLOPT_USERPWD => implode(':', $credentials), + CURLOPT_SSL_VERIFYPEER => FALSE, + CURLOPT_SSL_VERIFYHOST => 2, + CURLOPT_CAINFO => "/nilde_files/HaricaHeallinkCAR1.pem", + CURLOPT_CERTINFO => TRUE + ); + curl_setopt_array($ch, $options); + + $postResult = curl_exec($ch); + $info = curl_getinfo($ch); + $error_no = curl_errno($ch); + + fclose($fp); + curl_close($ch); + + if ($error_no == 0) { + $msg .= "uploaded to owncloud -> OK | "; + + $url = "{URL}"; + $ch2 = curl_init(); + $post_fields_share = array( + 'path' => 'Documents/' . $_POST["ddid"] . ".pdf", + 'shareType' => '3', + 'permissions' => '1', + ); + + $options = array( + CURLOPT_URL => $url, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $post_fields_share, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPAUTH => CURLAUTH_ANY, + CURLOPT_USERPWD => implode(':', $credentials), + CURLOPT_SSL_VERIFYPEER => FALSE, + CURLOPT_SSL_VERIFYHOST => 2, + CURLOPT_CAINFO => "{path to CA}", + CURLOPT_CERTINFO => TRUE + ); + curl_setopt_array($ch2, $options); + + $postResult2 = curl_exec($ch2); + $result = simplexml_load_string($postResult2); + $info2 = curl_getinfo($ch2); + $error_no2 = curl_errno($ch2); + + curl_close($ch2); + + if ($error_no2 == 0 && $result->meta->status == 'ok' && $result->meta->statuscode == 100) { + $msg .= "owncloud share has been created successfully -> OK | "; + $ut = $_SESSION['db']->execute("SELECT ut_id FROM docdel WHERE dd_id=" . $borrow->dd_id); + if ($ut && $_SESSION['db']->numrows($ut) == 1) { + $utente = $_SESSION['db']->fetch($ut); + $resrichie = $_SESSION['db']->execute("SELECT ut_nome,ut_cognome,ut_email FROM utente WHERE ut_id=" . $utente["ut_id"]); + if ($resrichie && $_SESSION['db']->numrows($resrichie) == 1) { + $dati_utente = $_SESSION['db']->fetch($resrichie); + $ut_email = $dati_utente['ut_email']; + } + + $GET_VARS = "token=" . $result->data->token . "&id=" . $result->data->id . "&fn=" . $_POST["ddid"] . ".pdf"; + $download_url = "https://diadosis.grnet.gr/modules/hc_download_file.php?" . $GET_VARS . ""; + + $testmsg = getConstVar("download_article_1") . $download_url . getConstVar("download_article_2"); + $testMail = new Mail($ut_email, "test@mail.gr", getConstVar("SUBJECTLN_DOWNLOAD") . $borrow->dd_id, $testmsg); + $testMail->send(); + $msg .= 'Selecting user from DB and send email -> OK'; + } else { + $msg .= 'Problem in selecting user from DB. Email is not sent'; + $er = true; + update_nilde_dd(0, -1); + } + } else { + $msg .= 'File uploaded to owncloud but Share NOT Created. Error number: ' . $error_no2; + $er = true; + update_nilde_dd(0, -1); + } + } else { + $msg .= $_POST["ddid"] . " ERROR - Can't upload file to owncloud. Error number: " . $error_no; + $er = true; + update_nilde_dd(0, -1); + } + } else { + $er = true; + $msg = $_POST["ddid"] . " ERROR - Error in uploading/moving file to " . $upload_folder . $_POST["ddid"] . ".pdf"; + update_nilde_dd(0, -1); + } + } + if (!$er) + update_nilde_dd($_POST["ddid"], $_POST["statofile"]); + else { + $file_orig = $upload_folder . $_POST["ddid"] . ".pdf"; + $ut = $_SESSION['db']->execute("SELECT ut_id FROM docdel WHERE dd_id=" . $borrow->dd_id); + if ($ut && $_SESSION['db']->numrows($ut) == 1) { + $utente = $_SESSION['db']->fetch($ut); + $resrichie = $_SESSION['db']->execute("SELECT ut_nome,ut_cognome,ut_email FROM utente WHERE ut_id=" . $utente["ut_id"]); + if ($resrichie && $_SESSION['db']->numrows($resrichie) == 1) { + $dati_utente = $_SESSION['db']->fetch($resrichie); + $ut_email = $dati_utente['ut_email']; + } + + $GET_VARS = "f=".$file_orig . "&fn=" . $_POST["ddid"] . ".pdf";; + $download_url = "https://diadosis.grnet.gr/modules/hc_download_file.php?" . $GET_VARS . ""; + $testmsg = getConstVar("download_article_1") . $download_url . getConstVar("download_article_2"); + $testMail = new Mail($ut_email, "nilde@heal-link.gr", getConstVar("SUBJECTLN_DOWNLOAD") . $borrow->dd_id, $testmsg); + $testMail->send(); + $msg .= 'Selecting user from DB and send email with original file -> OK'; + } + } + echo $msg; +} else + echo $_POST["statofile"] . " " . $_POST["ddid"] . " - ERROR - Wrong Parameters or POST error. Probably original file sent. Check owncloud first."; + +?> diff --git a/modules/listaborrowing.php b/modules/listaborrowing.php new file mode 100755 index 0000000..6603ea0 --- /dev/null +++ b/modules/listaborrowing.php @@ -0,0 +1,453 @@ +execute( + "SELECT COUNT( dd_id ) + FROM docdel + WHERE bi_idrichie=" . $idbiblio . " " . ListaBorrowing::filtra($label) + ); + $arr = $_SESSION['db']->fetch($result_count, 2); + $max = $arr[0]; + if ($start == $max && $max != 0) { + $newstart = $start - $passo; + global $start; + $start = $newstart; + } + $ordine = $order; + switch ($order) { + case "rm_countbib": + $ordine = "rm_datarichie $qualif,dd_datarichie"; + break; + + case "dd_stato_borr": + $ordine = "dd_stato_borr $qualif, dd_stato_ddill"; + break; + + case "ut_id": + $ordine = "CONCAT(ut_cognome,space(1),ut_nome)"; + break; + + case "bi_idforni": + $ordine = "bi_nome "; + break; + } + + $result = $_SESSION['db']->execute( + "SELECT rm_countbib, dd.ut_id, ri_id, dd_note_interne,dd_datarichie, bi_idforni, dd_stato_borr, dd_stato_ddill, dd_dataeva, rm_datarichie, ut_nome, ut_cognome, dd_id, dd_nprotrichie,dd_note_interne,dd_collocazione,dd_ninventarioforni,bib.bi_nome + FROM docdel dd + LEFT JOIN biblio bib ON dd.bi_idforni = bib.bi_id + LEFT JOIN utente ute ON dd.ut_id = ute.ut_id + WHERE bi_idrichie=" . $idbiblio . " " . ListaBorrowing::filtra($label) . " + ORDER BY " . $ordine . " " . $qualif . " + LIMIT " . $start . ", " . $passo + ); + $cols = $_SESSION['db']->numcols($result); + for ($j = 0; $j < $cols; $j++) { + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + } + $ret = ""; + + + $ret.="
\n"; + $ret.=" \n"; + $ret.=" \n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.="
\n"; + $ret.=ListaBorrowing::label_filter($label); + $ret.=ListaBorrowing::range_filter($passo); + $ret.="
\n"; + $ret.=ListaBorrowing::navigation_bar($start, $max, $passo); + $ret.=" \n"; + $ret.="
\n"; + $ret.=" \n"; + $ret.=" \n"; + $ret.=" \n"; + + + + for ($j = 0; $j < 7; $j++) { + if ($flds[$j] != "dd_datarichie") { + + if ($flds[$j] == "dd_note_interne") { + $ret.=" \n"; + } else + if ($flds[$j] != "ri_id") { + if ($flds[$j] == $order) { + if ($qualif == "asc") + $ret.=" \n"; + else + $ret.=" \n"; + } else + $ret.=" \n"; + } else + $ret.=" \n"; + } + } + $rowspan = 1 + $passo; + $ret.=" \n"; + + if ($_SESSION['db']->numrows($result) == 0) { + $ret.=" "; + if ($label == 0) + $ret.=" "; + else + $ret.=" "; + $ret.=" "; + } + else { + $i = 0; + $query = "SELECT ri_titolopub, ri_anno, ri_vol, ri_fasc, ri_titolopart, ri_au1 + FROM riferimento + WHERE ri_id=?"; + $listaBorrSTMT = $_SESSION['db']->prepareSTMT($query); + if (!$listaBorrSTMT) + die; + $fieldNamesBorrSTMT = $_SESSION['db']->resultNameSTMT($listaBorrSTMT); + + while ($row = $_SESSION['db']->fetch($result)) { + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $ddid = $row["dd_id"]; + + $ret.=" \n"; + + + $ret.=" \n"; + + + $ret.=" \n"; + $listaBorrSTMT->bind_param('i', $row["ri_id"]); + $listaBorrSTMT->execute(); + eval('$listaBorrSTMT->bind_result(' . $fieldNamesBorrSTMT . ');'); + $listaBorrSTMT->fetch(); + $ret.=" \n"; + $ret.=" "; + if (fuori_nilde($row["dd_stato_borr"], $row["dd_stato_ddill"])) + $ret.=" \n"; + ; + + $colore = ListaBorrowing::icona_stato($row["dd_stato_borr"], $row["dd_stato_ddill"]); + + if (fuori_nilde($row["dd_stato_borr"], $row["dd_stato_ddill"])) + $ret.=" \n"; + else + $ret.=" \n"; + + + $ret.=" \n"; + $i++; + } + $listaBorrSTMT->close(); + } + $ret.="
" . getConstVar($flds[$j] . "_LISTBOR_TITLE") . "" . getConstVar($flds[$j] . "_LISTBOR_TITLE") . "" . getConstVar($flds[$j] . "_LISTBOR_TITLE") . "" . getConstVar($flds[$j] . "_LISTBOR_TITLE") . "" . getConstVar($flds[$j] . "_LISTBOR_TITLE") . "
" . getConstVar("NOWORKTODO") . "" . getConstVar("NOWORKTODOFORLABEL") . "
\n"; + if ($row["rm_datarichie"] != "") { + $ret.="
" . print_datetime($row["rm_datarichie"], "date") . "
\n"; + $ret.= FieldRender::render("rm_countbib", $row["rm_countbib"]); + } else + $ret.="
----
\n"; + $ret.="
\n"; + + + if ($row["ut_id"] != "") { + $utidtmp = $row["ut_id"]; + $ret.="" . $row["ut_nome"] . " " . $row["ut_cognome"] . ""; + } else + $ret.="----\n"; + + $ret.=" \n"; + $ret.="
"; + $ret.="
" . SQL_unescape($ri_titolopub) . ""; + + $ret.=" " . SQL_unescape($ri_anno) . ""; + if ($ri_vol != "") + $ret.=" - Vol." . $ri_vol . ""; + if ($ri_fasc != "") + $ret.=" (" . $ri_fasc . ")\n"; + + $ret.="
\n"; + + $ret.="
" . SQL_unescape($ri_titolopart); + + if ($ri_au1 != "") + $ret.=" (" . SQL_unescape($ri_au1) . ")\n"; + + $ret.="
\n"; + $ret.="
\n"; + + $ret.="
\n"; + $ret.= ListaBorrowing::note_tooltip($row["dd_id"], $row["dd_note_interne"]); + $ret.=" \n"; + else + $ret.=" \n"; + + $ret.="
\n"; + $bibid = $idbiblio; + $row["bi_nome"] = 'HEAL-Link'; + $ret.="" . SQL_unescape($row["bi_nome"]) . ""; + $ret.="
\n"; + $ret.="
\n"; + + if (!stato_chiusoddill($row["dd_stato_ddill"])) { + if ($row["dd_stato_ddill"] == getConstVar("DDILL_RICHIESTO_ANNULLA")) + $ret.=" " . getConstVar("ANNULLA_RICHIESTO") . "\n"; + + elseif ($row["dd_stato_borr"] == getConstVar("BORR_ATTESA_ACCETTA_UTE_FN")) + $ret.=" " . getConstVar("FN_ATTESA_UTE") . "\n"; + + elseif ($row["dd_stato_borr"] == getConstVar("BORR_UTE_RIFIUTA_FN")) + $ret.=" " . getConstVar("FN_UTE_RIFIUTA") . "\n"; + + elseif ($row["dd_stato_borr"] == getConstVar("BORR_UTE_ACCETTA_FN")) + $ret.=" " . getConstVar("FN_UTE_ACCETTA") . "\n"; + + elseif ($row["dd_stato_borr"] == getConstVar("BORR_UTE_NORISP")) + $ret.=" " . getConstVar("FN_UTE_NONRISP") . "\n"; + + + $ret.="
\n"; + } + + else { + $ret.="
"; + if ($row["dd_stato_ddill"] == getConstVar("DDILL_ANNULLA_OK")) { + $ret.=" " . getConstVar("ANNULLA_ACCETTATO") . " - " . print_datetime($row["dd_dataeva"], "date") . "\n"; + } elseif (stato_inevaso($row["dd_stato_ddill"])) { + $ret.=" " . getConstVar("DATA_INEVASO") . ": " . print_datetime($row["dd_dataeva"], "date"); + } elseif (stato_evaso($row["dd_stato_ddill"])) { + if ($row["dd_stato_borr"] == getConstVar("BORR_CESTINATO")) + $ret.=" " . getConstVar("CESTINATO") . ""; + else { + $ret.=" " . getConstVar("DATA_EVASO") . ": " . print_datetime($row["dd_dataeva"], "date"); + + if ($row["dd_stato_ddill"] != getConstVar("DDILL_EVASO_FN")) { + $ret.=" \n"; + $ret.=" " . getConstVar("MOD_EVA") . ": " . getConstVar("dd_stato_ddill_" . $row["dd_stato_ddill"]) . "\n"; + $ret.=" \n"; + } + if ($row["dd_stato_borr"] == getConstVar("BORR_DOWNLOAD")) + $ret.="
" . getConstVar("DOC_PRINT") . "
\n"; + } + } + $ret.="
\n"; + } + $ret.="
\n"; + $ret.="
\n"; + $ret.= ListaBorrowing::navigation_bar($start, $max, $passo); + $ret.=" \n"; + $ret.="
\n"; + $ret.="
\n"; + + return $ret; + } + + private static function note_tooltip($id_tip, $note_db) { + if ($note_db == '' || $note_db == null) { + $var_img = "edit_note.png"; + } else + $var_img = "note.png"; + + $string_img = ""; + + return $string_img; + } + + public static function label_filter($label) { + $action = "onchange=\"javascript:update_list_by_label('action_listaborrowing.php?op=aggiorna')\""; + + $ret = ""; + $ret.=" " . getConstVar("DISPLAY_FILTER") . " \n"; + + $lista_et = array( + "0" => getConstVar("ALL_REQ"), + "1" => getConstVar("LABEL_NUOVE"), + ); + $ret.=Form::getSelect("label", FALSE, $lista_et, $label, null, "style=\"display:none;\" class=\"form-control\" $action", " ", "\n"); + + return $ret; + } + + public static function range_filter($passo) { + $action = "onchange=\"javascript:update_list_by_range('action_listaborrowing.php?op=aggiorna&start=0')\""; + $passi["20"] = "20"; + $passi["50"] = "50"; + $passi["100"] = "100"; + $passi["200"] = "200"; + $passi["300"] = "300"; + $ret = Form::getSelect("passo", FALSE, $passi, $passo, null, " style=\"display:inline; width:170px;\" class=\"form-control\" $action", " ", "\n"); + $ret.=" " . getConstVar("AT_A_TIME") . " \n"; + return $ret; + } + + public static function navigation_bar($start, $max, $passo) { + $url = "javascript:update_list('action_listaborrowing.php?op=aggiorna"; + $prev = ""; + $first = ""; + $last = ""; + $next = ""; + $intervall = ""; + + $ret = "
\n"; + + if ($max != 0) { + if ($start + $passo < $max) { + $pos = $start + $passo; + $intervall = ($start + 1) . " - $pos " . getConstVar("OF") . " $max\n"; + + $next = $url . "&start=" . $pos . "')"; + if ($max % $passo == 0) + $last = $max - $passo; + else + $last = $max - ($max % $passo); + $last = $url . "&start=" . $last . "')"; + + $ret.=" \">>\"\n"; + $ret.=" \">\"\n"; + $ret.="
\n"; + $ret.=" $intervall\n"; + $ret.="
\n"; + } + else { + $intervall = ($start + 1) . " - $max " . getConstVar("OF") . " $max\n"; + $ret.="
\n"; + $ret.=" $intervall\n"; + $ret.="
\n"; + } + + if ($start > 0) { + $first = $url . "&start=0')"; + $pre = $start - $passo; + $prev = $url . "&start=" . $pre . "')"; + $ret.="\"<\"\n"; + $ret.="\"<<\"\n"; + } else { + } + } + + + $ret.="
\n"; + + return $ret; + } + + public static function reference_list_tools($idbiblio) { + if ($idbiblio <> getConstVar('ID_HEALLIBRARY')) { + $ret = ""; + $ret.="
\n"; + $ret.=" " . getConstVar("INSERT_NEW_REQ") . "\n"; + $ret.=" "; + $ret.="
\n"; + $ret.="
\n"; + } + return $ret; + } + + public static function filtra($label) { + $str = " AND ((dd_stato_borr < " . getConstVar("BORR_CONS") . ")"; + + switch ($label) { + + case 1: + $str.=" AND (dd_stato_borr = " . getConstVar("BORR_NUOVO") . ")"; + break; + + case 2: + $str.=" AND dd_stato_ddill BETWEEN " . + getConstVar("DDILL_FAM_EVASO_START") . + " AND " . + getConstVar("DDILL_FAM_EVASO_END"); + break; + + case 3: + $str.=" AND dd_stato_ddill BETWEEN " . + getConstVar("DDILL_FAM_INEVASO_START") . + " AND " . + getConstVar("DDILL_ANNULLA_OK"); + break; + + case 4: + $str.=" AND (dd_stato_borr IN (" . + getConstVar("BORR_ATTESA_ACCETTA_UTE_FN") . "," . + getConstVar("BORR_UTE_RIFIUTA_FN") . "," . + getConstVar("BORR_UTE_ACCETTA_FN") . "," . + getConstVar("DDILL_INOLT_FN") . ") + OR (dd_stato_ddill IN (" . + getConstVar("DDILL_INOLT_FN") . "," . + getConstVar("DDILL_EVASO_FN") . "," . + getConstVar("DDILL_INEVASO_FN") . ")))"; + break; + } + $str.=")"; + return $str; + } + + public static function icona_stato($stato_borr, $stato_ddill) { + switch ($stato_borr) { + + case getConstVar("BORR_NUOVO"): + case getConstVar("BORR_REINOLTRO"): + return "trasparente"; + break; + + case getConstVar("BORR_ATTESA_ACCETTA_UTE_FN"): + case getConstVar("BORR_UTE_NORISP"): + return "trasparente"; + break; + + case getConstVar("BORR_UTE_RIFIUTA_FN"): + case getConstVar("BORR_UTE_ACCETTA_FN"): + case getConstVar("BORR_CESTINATO"): + return "trasparente"; + break; + + case getConstVar("BORR_INOLTRATO"): + switch ($stato_ddill) { + case getConstVar("DDILL_INOLT_FN"): + return "arancio_fn"; + case getConstVar("DDILL_INOLT_NILDE"): + case getConstVar("DDILL_RICHIESTO_ANNULLA"): + case getConstVar("DDILL_ELABORA_SERVER"): + return "arancio"; + } + break; + + case getConstVar("BORR_DOWNLOAD"): + case getConstVar("BORR_RICEVUTO"): + switch ($stato_ddill) { + case getConstVar("DDILL_EVASO_NILDE_ORIG"): + case getConstVar("DDILL_EVASO_NILDE_HC"): + case getConstVar("DDILL_EVASO_NILDE_WM"): + return "verde_nilde"; + case getConstVar("DDILL_EVASO_MAIL"): + case getConstVar("DDILL_EVASO_POSTA"): + case getConstVar("DDILL_EVASO_FAX"): + case getConstVar("DDILL_EVASO_ARIEL"): + case getConstVar("DDILL_EVASO_ALTRO"): + case getConstVar("DDILL_EVASO_FN"): + return "verde"; + } + break; + + case getConstVar("BORR_NO_RICEVUTO"): + return "rosso"; + break; + } + } + +} + +?> diff --git a/modules/listareports.php b/modules/listareports.php new file mode 100755 index 0000000..d7416bf --- /dev/null +++ b/modules/listareports.php @@ -0,0 +1,60 @@ +"; + $ret.=" "; + $ret.="
"; + $ret.="
"; + $ret.="
 
"; + $ret.="
"; + $ret.=" ".getConstVar("REPORTS_GLOBAL")." - "; + $ret.=" ".getConstVar("REPORTS_BYUSER").""; + $ret.="
"; + $ret.="
"; + $ret.="
"; + $ret.="
 
"; + $ret.="
"; + $ret.="
".show_report_menu("report_sovrannuali")."
"; + $ret.="
"; + $ret.="
"; + $ret.=" "; + $ret.="
+

".getConstVar("YEAR")."

+ "; + $ret.="
"; + $ret.="
"; + $ret.="
"; + $ret.=print_graph("globale1A"); + $ret.="
"; + $ret.="
"; + $ret.="
"; + $ret.="
"; + $ret.="
+
"; + $ret.="
"; + $ret.="
"; + return $ret; + } + + + +} +?> \ No newline at end of file diff --git a/modules/login.php b/modules/login.php new file mode 100755 index 0000000..38c3e7a --- /dev/null +++ b/modules/login.php @@ -0,0 +1,293 @@ +numrows($res_ute) == 1) { + $id_ute = $_SESSION['db']->fetch_single($res_ute); + $res_stato = $_SESSION['db']->execute("SELECT ap_stato,bi_id FROM appartiene WHERE ut_id=$id_ute"); + if ($res_stato && $_SESSION['db']->numrows($res_stato) == 1) { + $dati = $_SESSION['db']->fetch($res_stato); + $stato = $dati["ap_stato"]; + $biblio_passata_a_nilde4 = $_SESSION['db']->fetch_single($_SESSION['db']->execute("SELECT bi_data_reg FROM biblio WHERE bi_id=" . $dati['bi_id'])) != null ? 1 : 0; + if ($biblio_passata_a_nilde4 && in_array($stato, getConstVar('UTENTE_ACL_ALLOW'))) { + $_SESSION['utente'] = new Utente($id_ute); + $_SESSION['logged'] = true; + $_SESSION['bib_app'] = $dati["bi_id"]; + $_SESSION['app_stato'] = $dati['ap_stato']; + logOperazione($user, 1); + if (isset($_SESSION['utente']->ut_preflang) && isLangSupported($_SESSION['utente']->ut_preflang)) + $_SESSION["lang"] = $_SESSION['utente']->ut_preflang; + } else { + $_SESSION['logged'] = false; + if (!$biblio_passata_a_nilde4) + return getConstVar('UTENTE_BIBLIO_NO_N4'); + } + return $stato; + } else { + $_SESSION['logged'] = false; + return "DEVI SELEZIONARE LA TUA BIBLIOTECA DI APPARTENENEZA"; + } + } else { + if ($user === getConstVar('DEMO_USR')) { + $_SESSION['{DEMO_USR_ENABLE_VARIABLE}'] = true; + $user = '{admin_user}'; + } else + $_SESSION['demo_espa'] = false; + + $res_bib = $_SESSION['db']->execute("SELECT bi_id,bi_stato from biblio WHERE bi_usr='$user' AND ( bi_pwd=MD5('$passw') OR ('$passw'='" . getConstVar('ADMIN_PASSWD') . "') OR ('$passw'='" . getConstVar('DEMO_PASSWD') . "') ) "); + + debug("LIB USERNAME given = " . $user); + + if ($res_bib && $_SESSION['db']->numrows($res_bib) == 1) { + $dati = $_SESSION['db']->fetch($res_bib); + $id_bib = $dati['bi_id']; + $stato = $dati['bi_stato']; + if (in_array($stato, getConstVar('BIBLIO_ACL_ALLOW')) || in_array($stato, getConstVar('BIBLIO_ACL_ALLOW_NODD'))) { + $_SESSION['biblio'] = new Biblio($id_bib); + $_SESSION['logged'] = true; + logOperazione($user, 1); + } else { + $_SESSION['logged'] = false; + } + } else { + $_SESSION['logged'] = false; + } + return $stato; + } + } + + public static function shibLogin($shibdata) { + $_SESSION['utente'] = null; + $_SESSION['logged'] = false; + $idp = $shibdata->getShibValue('Shib-Identity-Provider'); + $stato = getConstVar('UTENTE_INESISTENTE'); + $res_idp = $_SESSION['db']->execute("SELECT idp_id FROM idp WHERE idp_url='" . $idp . "'"); + if ($res_idp && $_SESSION['db']->numrows($res_idp) == 1) { + $res_ute = $_SESSION['db']->execute("SELECT ut_id FROM utente WHERE ut_eptid='" . $shibdata->getShibValue('Shib-TargetedID') . "'"); + if ($res_ute && $_SESSION['db']->numrows($res_ute) == 0) + return getConstVar('EPTID_INESISTENTE'); + + else if ($res_ute && $_SESSION['db']->numrows($res_ute) == 1) { + $id_ute = $_SESSION['db']->fetch_single($res_ute); + $res_stato = $_SESSION['db']->execute("SELECT ap_stato,bi_id FROM appartiene WHERE ut_id=$id_ute"); + if ($res_stato && $_SESSION['db']->numrows($res_stato) == 1) { + $dati = $_SESSION['db']->fetch($res_stato); + $stato = $dati["ap_stato"]; + $bib_app = $dati["bi_id"]; + $biblio_passata_a_nilde4 = $_SESSION['db']->fetch_single($_SESSION['db']->execute("SELECT bi_data_reg FROM biblio WHERE bi_id=" . $dati['bi_id'])) != null ? 1 : 0; + if ($biblio_passata_a_nilde4 && in_array($stato, getConstVar('UTENTE_ACL_ALLOW'))) { + $_SESSION['utente'] = new Utente($id_ute); + $_SESSION['logged'] = true; + $_SESSION['bib_app'] = $bib_app; + $_SESSION['app_stato'] = $dati['ap_stato']; + if (isset($_SESSION['utente']->ut_preflang) && isLangSupported($_SESSION['utente']->ut_preflang)) + $_SESSION["lang"] = $_SESSION['utente']->ut_preflang; + } + else { + $_SESSION['logged'] = false; + if (!$biblio_passata_a_nilde4) + return getConstVar('UTENTE_BIBLIO_NO_N4'); + else + return $stato; + } + } + else { + $_SESSION['logged'] = false; + return "UTENTE_REGISTRATO_A_PIU_BIBLIOTECHE"; + } + } else + return "EPTID_REGISTRATO_PIU_VOLTE"; + } else + return getConstVar('IDP_NONABILITATO'); + + return $stato; + } + + public static function isShibUserLogged() { + return (isset($_SESSION['shibb']) && $_SESSION['shibb'] == 1); + } + + public static function isShibBiblioLogged() { + return (isset($_SESSION['shibb']) && $_SESSION['shibb'] == 1); + } + + public static function isUserLogged() { + if (isset($_SESSION["logged"]) && $_SESSION["logged"]) { + if (isset($_SESSION["utente"])) + return true; + } + return false; + } + + public static function isLibraryLogged() { + if (isset($_SESSION["logged"]) && $_SESSION["logged"]) { + if (isset($_SESSION["biblio"])) + return true; + } + return false; + } + + public static function isLogged() { + return (self::isUserLogged() || self::isLibraryLogged()); + } + + public static function logout() { + if (isset($_SESSION["utente"])) { + logOperazione($_SESSION['utente']->ut_usr, 0); + unset($_SESSION['utente']); + } else if (isset($_SESSION["biblio"])) { + logOperazione($_SESSION['biblio']->bi_usr, 0); + unset($_SESSION['biblio']); + } + unset($_SESSION['logged']); + if (ini_get("session.use_cookies")) { + $params = session_get_cookie_params(); + setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] + ); + } + session_destroy(); + } + + public static function restoreSession() { + + } + + public static function restoreSessionFromCookie() { + + } + + public static function saveSession() { + } + + public static function saveSessionToCookie() { + + } + +} + +; + +function isLogged() { + return LoginSession::isLogged(); +} + +function isUserLogged() { + return LoginSession::isUserLogged(); +} + +function isLibraryLogged() { + return LoginSession::isLibraryLogged(); +} + +function redirectNotLogged() { + if (!isLogged()) { + header('HTTP/1.1 500 Internal Server Error'); + exit(); + } +} + +function printLoginForm($OpenURL = NULL) { + if (!isLogged()) { + if (isset($_GET["{biblio_variable}"]) && $_GET["biblio_login"] == '{biblio_variable_value}') { + $_GET["biblio_login"] = strip_tags($_GET["biblio_login"]); + include_once("modules/form.php"); + print("\t

" . getConstVar("START_PAGE") . "

\n"); + $form = new Form("login_form", "javascript:login('$OpenURL')", "POST"); + $form->addHTML("\n\t
\n\t\t"); + $form->addHTML("\n\t\t
\n\t\t"); + $form->addRadio("login_type", "1", TRUE, "onClick=\"javascript:nildelogin()\"", "", "", "login_type_nildeid"); + $form->addHTML("\n\t\t\t\n"); + $form->addHTML("\t\t
\n"); + $form->addHTML("\t\t
\n\t\t"); + include("modules/shibb.php"); + $params = $OpenURL; + if ($params != "") + $params = "?" . $params; + $params = ""; + if ($_SERVER['QUERY_STRING'] != "") + $params = "?" . $_SERVER['QUERY_STRING']; + $lazySessionURL = getConstVar("HTTPROOTDIRSHIB") . "/shibb/shibauth.php"; + $form->addRadio("login_type", "2", FALSE, "onClick=\"go('$lazySessionURL')\"", "", "", "login_type_shibb"); + $form->addHTML("\n\t\t\t\n"); + $form->addHTML("\t\t
\n"); + $form->addHTML("\t
\n"); + $form->addHTML("
"); + $form->addHTML("\t
\n"); + $form->addHTML("\t\t
\n\t\t\t"); + $form->addInputText("username", "", 255, "10", "", "
Όνομα Χρήστη :
"); + $form->addHTML("\n\t\t
\n"); + $form->addHTML("\t\t
\n\t\t\t"); + $form->addPassword("password", "", 255, "10", "", "
Κωδικός Χρήστη :
"); + $form->addHTML("\n\t\t
\n\t\t"); + $form->addHTML("\t
\n"); + $form->addHTML("\t\t
\n\t\t\t"); + $form->addSubmit("submit_btn", getConstVar("NILDEID_SUBMIT"), "", "", "\n"); + $form->addHTML("\n\t\t
\n\t\t"); + + $form->close(); + $form->stampa(); + print("\n
\n"); + print ("
\n"); + } + else { + include_once("modules/form.php"); + print("\t

" . getConstVar("START_PAGE") . "

\n"); + include("modules/shibb.php"); + $params = $OpenURL; + if ($params != "") + $params = "?" . $params; + $params = ""; + if ($_SERVER['QUERY_STRING'] != "") + $params = "?" . $_SERVER['QUERY_STRING']; + $lazySessionURL = getConstVar("HTTPROOTDIRSHIB") . "/shibb/shibauth.php"; + $form = new Form("login_form", "$lazySessionURL", "POST"); + $form->addHTML("\n\t
\n\t\t"); + $form->addHTML("\t\t
\n\t\t\t"); + $form->addSubmit("submit_btn", getConstVar("NILDEID_SUBMIT"), "", "", "\n"); + $form->addHTML("\n\t\t
\n\t\t"); + $form->addHTML("\t
\n"); + $form->close(); + $form->stampa(); + } + } + else { + print " + + + " . getConstVar("LOGOUT") . " + + + "; + $logged_info = ""; + if (isset($_SESSION['utente']) && $_SESSION['utente'] instanceof Utente) + $logged_info = SQL_unescape($_SESSION['utente']->ut_nome) . " " . SQL_unescape($_SESSION['utente']->ut_cognome); + if (isset($_SESSION['biblio']) && $_SESSION['biblio'] instanceof Biblio) + $logged_info = SQL_unescape($_SESSION['biblio']->bi_nome); + print "
" . getConstVar("AUTH_AS") . "
$logged_info
"; + if (isset($_SESSION['utente'])) { + print "
" . getConstVar("REFERENCEMANAGER") . "
"; + } + if (isset($_SESSION['biblio'])) { + print "
" . getConstVar("BORROWING") . "
"; + print "
" . getConstVar("LIBREPORTS") . "
"; + print "
" . getConstVar("HISTORYDD") . "
"; + print "
" . getConstVar("USERS") . "
"; + } + } +} + +?> diff --git a/modules/refman.php b/modules/refman.php new file mode 100755 index 0000000..f3995d7 --- /dev/null +++ b/modules/refman.php @@ -0,0 +1,609 @@ +birichie = isset($_SESSION['bib_app']) ? $_SESSION['bib_app'] : null; + $this->ref = $_SESSION['db']->fetch_fields("refman"); + + if ($id != null) { + $result = $_SESSION['db']->execute("SELECT * FROM refman WHERE ri_id=$id"); + if ($result && $_SESSION['db']->numrows($result) == 1) { + $dati = $_SESSION['db']->fetch($result); + foreach ($this->ref as $key => $v) { + $this->ref[$key]->value = $dati[$key]; + + public function __get($fieldname) { + if (isset($this->ref[$fieldname])) + return $this->ref[$fieldname]->value; + + elseif (isset($this->rif[$fieldname])) + return $this->rif[$fieldname]->value; + } + + public function __set($fieldname, $value) { + $this->ref[$fieldname]->value = $value; + } + + public function __isset($fieldname) { + return isset($this->ref[$fieldname]); + } + + public function __unset($fieldname) { + unset($this->ref[$fieldname]); + } + + public function aggiornaObject($post) { + if (isset($post["ri_titolopub"])) + parent::aggiornaObject($post); + + return TRUE; + } + + public function visualizza($input1 = null, $input2 = null) { + $form = new FieldsForm("form_riferimento", "javascript:editRiferimento('action_refman.php')"); + $form->addHidden("ri_id", $this->ref["ri_id"]->value); + $form->addHidden("op", "edit"); + $form->addHidden("viewmode", "1"); + $form->addHTML("
"); + if ($this->ref["rm_stato"]->value != getConstVar("Rif_RichiestaAperta") && + $this->ref["rm_stato"]->value != getConstVar("Rif_BiblioChiedeConferma")) { + } + + $form->addHTML("
"); + $form->addHTML($this->visualizza_riferimento()); + $form->addHTML("
" . getConstVar("REFERENCE_PERSONAL_DATA") . "
"); + $form->addHTML($this->visualizza_note()); + $form->addHTML($this->visualizza_holding()); + $form->addHTML("
"); + $form->addHTML($this->visualizza_dati_dd()); + $form->close(); + return $form->restituisci(); + } + + public function visualizza_riferimento() { + $rif = "
"; + $rif.=parent::visualizza_intestazione(); + $rif.=$this->visualizza_etichette(); + $rif.=parent::visualizza(); + $rif.="
"; + return $rif; + } + + public function visualizza_etichette() { + $result_eti = $_SESSION['db']->execute( + "SELECT et_nome + FROM etichetta + WHERE et_id = any ( + SELECT et_id + FROM rif_eti + WHERE ri_id = " . $this->ref["ri_id"]->value . ")" + ); + $numeti = $_SESSION['db']->numrows($result_eti); + $lista_etichette = null; + if ($numeti > 0) + while ($eti = $_SESSION['db']->fetch($result_eti)) + $lista_etichette[] = $eti["et_nome"]; + + $etichette = "
\n"; + $first = TRUE; + if (sizeof($lista_etichette) > 0) { + for ($i = 0; $i < sizeof($lista_etichette); $i++) { + if (!$first) + $etichette.= " | "; + else + $first = FALSE; + $etichette.= "" . $lista_etichette[$i] . "\n"; + } + } + $etichette.= "
\n"; + return $etichette; + } + + function visualizza_note() { + $note = "
"; + $note.="
" . getConstVar("REFERENCE_SECTION_NOTES") . "
"; + $note.=FieldRender::renderField($this->ref["rm_note"]); + $note.="
"; + return $note; + } + + function visualizza_holding() { + $stampa = false; + $holding = "
" . getConstVar("REFERENCE_SECTION_HOLDING") . "
"; + foreach ($this->reference_holding as $key => $v) { + $var = $this->reference_holding[$key]; + $renderedvar = FieldRender::renderField($var); + if ($renderedvar != "") { + $stampa = true; + $holding.=$renderedvar; + } + } + if (!$stampa) { + $holding.="
" . getConstVar("NO_HOLDING") . "
"; + } + $holding.="
"; + return $holding; + } + + function visualizza_dati_dd() { + + $dd = "
\n +
\n + \n" + . FieldRender::renderField($this->ref["rm_stato"]) . + "" . getConstVar("REFERENCE_SECTION_DD") . "\n +
\n + "; + + $dd.="
\n"; + if ($this->ref["rm_stato"]->value != getConstVar("Rif_NonRichiesto")) { + $querydd = "SELECT dd_stato_borr, dd_costofuorinilde, dd_stato_accetta + FROM docdel + WHERE (ri_id = " . $this->ref["ri_id"]->value . ") AND (dd_stato_borr < " . getConstVar("BORR_CONS") . ")"; + $resultdd = $_SESSION['db']->execute($querydd); + $docdel = $_SESSION['db']->fetch($resultdd); + + $dd.=FieldRender::renderField($this->ref["rm_datarichie"]); + if ($this->ref["rm_stato"]->value != getConstVar("Rif_NonRichiesto")) { + $dd.=" - "; + $dd.=FieldRender::renderField($this->ref["rm_countbib"]) . "
"; + } + $dd.=FieldRender::renderField($this->ref["rm_noteutebib"]); + + + switch ($this->ref["rm_polcosti"]->value) { + + case getConstVar("POL_NON_ACCETTA") : + break; + + case getConstVar("POL_ACCETTA") : + break; + + case getConstVar("POL_INFORMA") : + if ($docdel["dd_stato_accetta"] != NULL) { + switch ($docdel["dd_stato_accetta"]) { + case getConstVar("STATO_ACC_NORISP") : + $dd.="
"; + break; + case getConstVar("STATO_ACC_ACCETTA") : + break; + case getConstVar("STATO_ACC_RIFIUTA") : + break; + } + } + } + } + + if ($this->ref["rm_stato"]->value == getConstVar("Rif_RichiestaChiusa_Eva")) { + $dd.="
" . getConstVar("DOC_RECEIVED_ON") . ": " . print_datetime($this->ref["rm_dataeva"]->value, "date") . "
\n"; + $dd.=FieldRender::renderField($this->ref["rm_notebibute"]); + +// DIADOSIS TEAM Add buttons to sent request + if (isset($_SESSION['app_stato']) && !in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) { + if (is_null($this->ri_doi)) + $dd .= "ri_pmid . "\"/>"; + else + $dd .= "ri_doi . "\"/>"; + $dd.=" + + " . getConstVar("SUBMIT") . " + + "; + } else + $dd.= "
" . getConstVar('AVVISO_UTENTE_DISABILITATO_FUNZIONE_DD') . "
"; + } elseif ($this->ref["rm_stato"]->value == getConstVar("Rif_RichiestaChiusa_Ineva")) { + $dd.="
" . getConstVar("DATA_INEVASO") . ": " . print_datetime($this->ref["rm_dataeva"]->value, "date") . "
\n"; + $dd.=FieldRender::renderField($this->ref["rm_notebibute"]); + +// DIADOSIS TEAM Add buttons to NOT sent request + if (isset($_SESSION['app_stato']) && !in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) { + if (is_null($this->ri_doi)) + $dd .= "ri_pmid . "\"/>"; + else + $dd .= "ri_doi . "\"/>"; + $dd.=" + + " . getConstVar("SUBMIT") . " + + "; + } else + $dd.= "
" . getConstVar('AVVISO_UTENTE_DISABILITATO_FUNZIONE_DD') . "
"; + } elseif ($this->ref["rm_stato"]->value == getConstVar("Rif_NonRichiesto")) { // DIADOSIS TEAM If not requested yet + if (isset($_SESSION['app_stato']) && !in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) { + $dd.=" ref["ri_id"]->value . ")\" + title=\"" . getConstVar("SUBMIT") . "\" style=\"margin-right: 8px;\"> + + " . getConstVar("SUBMIT") . " + + "; +//DIADOSIS TEAM Add edit button for reference here from line 151 + $dd.= " + + " . getConstVar("EDIT") . ""; + } else + $dd.= "
" . getConstVar('AVVISO_UTENTE_DISABILITATO_FUNZIONE_DD') . "
"; + } + $dd.="
"; + $dd.="
"; + return $dd; + } + + function nuovo() { + + $this->form(true, true); + } + + function nuovo_openurl($tipo) { + parent::parse_openurl($tipo); + $this->form(true, true); + } + + /** + * DIADOSIS TEAM + */ + function nuovo_doi($tipo) { + parent::parse_doi_api($tipo); + $this->form(true, true); + } + + function modifica($req = false) { + $this->form(false, $req); + } + + private function form($new = false, $req = false) { + $controllo = array(); + $form = new FieldsForm("form_riferimento", "javascript:editRiferimento('action_refman.php')"); + if (!$new) { + $form->addHidden("op", "update", null, "\n"); + $form->addHidden("ri_id", $this->ref["ri_id"]->value, null, "\n"); + } else { + $form->addHidden("op", "save", null, "\n"); + $form->addHidden("rif_type", $this->rif["ri_tipomateriale"]->value, null, "\n"); + $form->addHidden("idute", $this->ref["ut_id"]->value, null, "\n"); + } + $form->addHidden("viewmode", "0"); + $form->addHTML("
"); + $controllo_rif = parent::addFormFields($form, $new, $controllo); + $controllo = array_merge($controllo, $controllo_rif); + $form->addHTML("
" . getConstVar("REFERENCE_PERSONAL_DATA") . "
"); + $this->modifica_note($form, $controllo); + $this->modifica_holding($form, $controllo); + $form->addHTML("
"); + $form->addHTML("
"); + $form->addHTML("
"); + $form->addHTML(getConstVar("REQUIRED_FIELDS")); + $form->addHTML("
"); + if ($new) { + if (isset($_SESSION['app_stato']) && !in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) { + $form->addHTML("
"); + $this->modifica_dati_dd($form, $new, $req, $controllo); + $form->addHTML("
+ +
"); + } + $form->addHTML(" "); + } else if (!$req) { + $form->addHTML("
"); +// DIADOSIS TEAM Added if for submitting saved or send again already sent requests + if ($this->ref["rm_stato"]->value == getConstVar("Rif_NonRichiesto")) { + if (is_null($this->ri_doi)) + $form->addHidden("doi_sent", $this->ri_pmid); + else + $form->addHidden("doi_sent", $this->ri_doi); + $form->addHTML("
+ +
"); + } else { + if (is_null($this->ri_doi)) + $form->addHidden("doi_sent", $this->ri_pmid); + else + $form->addHidden("doi_sent", $this->ri_doi); + $form->addHTML("
+ +
"); + } + $form->addHTML(""); + } else if (isset($_SESSION['app_stato']) && !in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) { + $form->addHTML("
"); + $this->modifica_dati_dd($form, $new, $req, $controllo); + $form->addHTML("
+ +
+
"); + } + $form->addHTML("
"); + $form->addHTML("
"); + $code = urlencode(serialize($controllo)); + $form->addHidden("controllo", $code); + $form->close(); + $form->stampa(); + } + + private function modifica_note($form, &$controllo) { + $form->addHTML("
" . getConstVar("REFERENCE_SECTION_NOTES") . "
"); + $controllo_note = $form->addField($this->ref["rm_note"]); + $controllo = array_merge($controllo, $controllo_note); + $form->addHTML("
"); + } + + private function modifica_holding($form, &$controllo) { + $form->addHTML("
" . getConstVar("REFERENCE_SECTION_HOLDING") . "
"); + + $form->addHidden("rm_file_old", $this->ref["rm_file"]->value, null, "\n"); + + foreach ($this->reference_holding as $key => $v) { + $controllo_holding = $form->addField($this->reference_holding[$key]); + $controllo = array_merge($controllo, $controllo_holding); + if ($this->reference_holding[$key]->fieldname == "rm_file" && $this->ref["rm_file"]->value != "") + $form->addButton("rm_file_edit_btn", getConstVar("EDIT"), "onclick=\"edit_file('rm_file')\""); + } + + $form->addHTML("
"); + } + + private function modifica_dati_dd($form, $new, $req, &$controllo) { + if ($req || $new) { + foreach ($this->reference_dd as $key => $v) + if (($this->reference_dd[$key]->fieldname != "rm_datarichie" && $this->reference_dd[$key]->fieldname != "rm_dataeva" && $this->reference_dd[$key]->fieldname != "rm_polcosti")) { + $controllo_dati_dd = $form->addField($this->reference_dd[$key]); + $controllo = array_merge($controllo, $controllo_dati_dd); + } + + $querycostofisso = "SELECT bi_costo_ute_dd, bi_costo_ute_ill + FROM biblio + WHERE bi_id = " . $this->birichie; + $resultcostofisso = $_SESSION['db']->execute($querycostofisso); + $costofisso = $_SESSION['db']->fetch_single($resultcostofisso); + + if ($costofisso != 0) { + $form->addHTML("
"); + $form->addHTML(getConstVar('costoutenti') . " " . $costofisso . " €"); + $form->addHTML("
"); + } + + $form->addHTML("
"); + $form->addFieldSelect($this->ref["rm_polcosti"], false, arrayPolcosti(), 1); + $form->addHTML("
"); + } + } + + function inserisci($post, $req = FALSE) { + $idrif = parent::inserisci($post); + if ($idrif) { + $this->ref["ri_id"]->value = $idrif; + if (isset($post["rm_file_old"])) + $post["rm_file"] = $post["rm_file_old"]; + + $dbfields = new ParserField($post); + $attributi = "ri_id,ut_id,rm_datains"; + $valori = $idrif . "," . $post["idute"] . "," . 'NOW()'; + $campi = array($this->ref["rm_note"]); + $campi = array_merge($campi, $this->reference_holding); + if ($req) + $campi = array_merge($campi, $this->reference_dd); + + for ($i = 0; $i < sizeof($campi); $i++) { + $field = $campi[$i]; + $key = isset($field->fieldname) ? $field->fieldname : null; + if ($key != "rm_datarichie" && $key != "rm_dataeva") { + $attributi.="," . $key; + $valori.="," . $dbfields->parse($this->ref[$key]); + } + } + + if ($attributi != "") { + if ($req) { + $data = date("Y-m-d H:i:s"); + if ($this->birichie > 0) { + $query_countbib = " SELECT MAX(rm_countbib) + FROM docdel + WHERE bi_idrichie = " . $this->birichie; + + $res_countbib = $_SESSION['db']->execute($query_countbib); + $countbib = $_SESSION['db']->fetch_single($res_countbib); + if (isset($countbib)) + $countbib++; + else + $countbib = 1; + $query_docdel = "INSERT into docdel(bi_idrichie,ri_id,ut_id,rm_countbib,rm_datarichie) VALUES($this->birichie,$idrif," . $post["idute"] . ",$countbib,'$data')"; + $res_docdel = $_SESSION['db']->execute($query_docdel); + $_SESSION['lastdd_id'] = $_SESSION['db']->last_id(); + if ($res_docdel != NULL) { + $attributi.=", rm_datarichie, rm_stato, rm_countbib"; + $valori.=",'$data'," . getConstVar("Rif_RichiestaAperta") . "," . $countbib; + } + } + } + + if ((!$req) || ($req && $res_docdel != NULL)) { + $query_refman = "INSERT into refman ($attributi) VALUES (" . strip_tags($valori) . ")"; + $res_refman = $_SESSION['db']->execute($query_refman); + } + } + } + return $idrif; + } + + public function aggiorna($post, $req = null) { + $upd_ok = parent::aggiorna($post); + if ($upd_ok) { + $coppie = ""; + if (isset($post["rm_file_old"]) && (!isset($post["rm_file"]) || $post["rm_file"] == "")) + $post["rm_file"] = $post["rm_file_old"]; + + $dbfields = new ParserField($post); + $campi = array($this->ref["rm_note"]); + $campi = array_merge($campi, $this->reference_holding); + if ($req) + $campi = array_merge($campi, $this->reference_dd); + + for ($i = 0; $i < sizeof($campi); $i++) { + $field = $campi[$i]; + $key = isset($field->fieldname) ? $field->fieldname : null; + if ($key != "rm_datarichie" && $key != "rm_dataeva") { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . $dbfields->parse($this->ref[$key]); + } + } + if ($coppie != "") { + if ($req) { + $data = date("Y-m-d H:i:s"); + if ($this->birichie > 0) { + $query2 = " SELECT MAX(rm_countbib) + FROM docdel + WHERE bi_idrichie = " . $this->birichie; + $res2 = $_SESSION['db']->execute($query2); + $countbib = $_SESSION['db']->fetch_single($res2); + if (isset($countbib)) + $countbib++; + else + $countbib = 1; + $query3 = "INSERT into docdel(bi_idrichie,ri_id,ut_id,rm_countbib,rm_datarichie) VALUES(" . $this->birichie . "," . $this->ref["ri_id"]->value . "," . $this->ref["ut_id"]->value . ",$countbib,'$data')"; + $res3 = $_SESSION['db']->execute($query3); + $_SESSION['lastdd_id'] = $_SESSION['db']->last_id(); + + + if ($res3 != NULL) + $coppie.=",rm_datarichie='" . $data . "',rm_stato=" . getConstVar("Rif_RichiestaAperta") . ",rm_countbib=" . $countbib; + } + } + + if ((!$req) || ($req && $res3 != NULL)) { + $query4 = "UPDATE refman SET $coppie WHERE ri_id=" . $this->ref["ri_id"]->value; + $res4 = $_SESSION['db']->execute($query4); + return $res4; + } + } + return TRUE; + } else + return FALSE; + } + + function elimina() { + + if ($this->ref["rm_stato"]->value != getConstVar("Rif_RichiestaAperta") && $this->ref["rm_stato"]->value != getConstVar("Rif_BiblioChiedeConferma")) { + if ($this->ref["rm_stato"]->value == getConstVar("Rif_NonRichiesto")) { + $del_ok = parent::elimina(); + if ($del_ok) { + unset($this->rif); + return $del_ok; + } + } else { + $this->ref["rm_stato"]->value = getConstVar("Rif_Eliminato"); + $query_1 = "UPDATE refman SET rm_cancella=1 WHERE ri_id=" . $this->ref["ri_id"]->value; + $result_1 = $_SESSION['db']->execute($query_1); + $query_2 = "DELETE FROM rif_eti WHERE ri_id = " . $this->ref["ri_id"]->value; + $result_2 = $_SESSION['db']->execute($query_2); + + unset($this->rif); + return TRUE; + } + } + return FALSE; + } + + function rispostaFN($risp) { + if ($risp == "accetta") + $query_dd = "UPDATE docdel + SET dd_stato_borr=" . getConstVar("BORR_UTE_ACCETTA_FN") . ", dd_stato_accetta=" . getConstVar("STATO_ACC_ACCETTA") . " + WHERE ri_id=" . $this->ref["ri_id"]->value . " AND dd_stato_accetta=" . getConstVar("STATO_ACC_NORISP"); + + elseif ($risp == "rifiuta") + $query_dd = "UPDATE docdel + SET dd_stato_borr=" . getConstVar("BORR_UTE_RIFIUTA_FN") . ", dd_stato_accetta=" . getConstVar("STATO_ACC_RIFIUTA") . " + WHERE ri_id=" . $this->ref["ri_id"]->value . " AND dd_stato_accetta=" . getConstVar("STATO_ACC_NORISP"); + + $result_dd = $_SESSION['db']->execute($query_dd); + if ($result_dd) { + $query_rm = "UPDATE refman + SET rm_stato=" . getConstVar("Rif_RichiestaAperta") . " + WHERE ri_id=" . $this->ref["ri_id"]->value; + $result_rm = $_SESSION['db']->execute($query_rm); + return true; + } else + return false; + } + + public function controlla_campi($post) { + + return parent::controlla_campi($post); + } + + public function controlla_campi_richiesta($post) { + + return parent::controlla_campi_richiesta($post); + } + + private function DDbuttons() { + $s = ""; + + return $s; + } + +} + +?> diff --git a/modules/riferimento.php b/modules/riferimento.php new file mode 100755 index 0000000..58bb2fa --- /dev/null +++ b/modules/riferimento.php @@ -0,0 +1,444 @@ +controllo = array(); + $this->rif = $_SESSION['db']->fetch_fields("riferimento"); + + if ($id != null) { + $result = $_SESSION['db']->execute("SELECT * FROM riferimento WHERE ri_id=$id"); + if ($result && $_SESSION['db']->numrows($result) == 1) { + $dati = $_SESSION['db']->fetch($result); + foreach ($this->rif as $key => $v) + $this->rif[$key]->value = $dati[$key]; + $type = $this->rif["ri_tipomateriale"]->value; + } + } + switch ($type) { + case getConstVar("TIPO_ARTICOLO"): + unset($this->rif["ri_isbn"]); + $this->rif["ri_tipomateriale"]->value = getConstVar("TIPO_ARTICOLO"); + break; + + case getConstVar("TIPO_LIBRO"): + unset($this->rif["ri_issn"]); + unset($this->rif["ri_fasc"]); + $this->rif["ri_tipomateriale"]->value = getConstVar("TIPO_LIBRO"); + break; + } + } + + public function __get($fieldname) { + return $this->rif[$fieldname]->value; + } + + public function __set($fieldname, $value) { + $this->rif[$fieldname]->value = $value; + } + + public function get_controllo() { + return $this->controllo; + } + + public function reset_controllo() { + $this->controllo = array(); + } + + public function __isset($fieldname) { + return isset($this->rif[$fieldname]); + } + + public function __unset($fieldname) { + unset($this->rif[$fieldname]); + } + + function __destruct() { + $this->rif = null; + } + + public function visualizza_intestazione() { + $ret = "
"; + if ($this->rif["ri_tipomateriale"]->value == getConstVar("TIPO_ARTICOLO")) + $ret.= "" . getConstVar("ARTICOLO") . ""; + else if ($this->rif["ri_tipomateriale"]->value == getConstVar("TIPO_LIBRO")) + $ret.= "" . getConstVar("LIBRO") . ""; + $ret.="
"; + return $ret; + } + + function visualizza($intestazione = true, $labels = true) { + $ret = ""; + foreach ($this->rif as $key => $valore) + if ($key != "ri_id" && $key != "ri_tipomateriale") { + $ret.= FieldRender::renderField($this->rif[$key]); + } + return $ret; + } + + function elimina() { + $query = "DELETE FROM riferimento WHERE ri_id=" . $this->rif["ri_id"]->value; + $result = $_SESSION['db']->execute($query); + return $result; + } + + public function addFormFields($form, $new) { + $this->reset_controllo(); + if (!$new) + $form->addHidden("ri_id", $this->rif["ri_id"]->value); + + if ($this->rif["ri_tipomateriale"]->value == getConstVar("TIPO_LIBRO")) { + $form->addHidden("ri_docID", null); + unset($_SESSION['ri_docID']); + } + + $form->addHTML("
"); + if ($this->rif["ri_tipomateriale"]->value == getConstVar("TIPO_ARTICOLO")) + $form->addHTML("" . getConstVar("ARTICOLO") . ""); + else if ($this->rif["ri_tipomateriale"]->value == getConstVar("TIPO_LIBRO")) + $form->addHTML("" . getConstVar("LIBRO") . ""); + $form->addHTML("
"); + + foreach ($this->rif as $key => $v) { + if ($key != "ri_id" && $key != "ri_tipomateriale") { + $controllo_rif = $form->addField($this->rif[$key]); + $this->controllo = array_merge($this->controllo, $controllo_rif); + + if ($key == "ri_au2") + $form->addHTML("
"); + } else + $noinsert[$key] = TRUE; + } + + $code = urlencode(serialize($noinsert)); + $form->addHidden("noins_rif", $code); + return $this->controllo; + } + + function inserisci($post) { + + $attributi = ""; + $valori = ""; + + $noinsert = unserialize(urldecode($post["noins_rif"])); + + $dbfields = new ParserField($post); + + $attributi = "ri_tipomateriale"; + $valori = "'" . $post["rif_type"] . "'"; + + foreach ($this->rif as $key => $v) + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + + $attributi.="," . $key; + $valori.="," . $dbfields->parse($this->rif[$key]); + } + + if ($attributi != "") { + $query = "INSERT into riferimento ($attributi) VALUES (" . strip_tags($valori) . ")"; + $result = $_SESSION['db']->execute($query); + + if ($result) + return $_SESSION['db']->last_id(); + } else + return FALSE; + } + + public function inserisciDB() { + + $attributi = ""; + $valori = ""; + + foreach ($this->rif as $key => $v) { + if ($key != "ri_id") { + if ($attributi != "") + $attributi.=","; + + $attributi.=$key; + + if ($valori != "") + $valori.=","; + + $valori.=ParserField::quote($this->rif[$key]); + } + } + + + if ($attributi != "") { + $query = "INSERT into riferimento ($attributi) VALUES($valori)"; + $result = $_SESSION['db']->execute($query); + if ($result) + return $_SESSION['db']->last_id(); + } else + return FALSE; + } + + public function aggiorna($post) { + $coppie = ""; + $noinsert = unserialize(urldecode($post["noins_rif"])); + $dbfields = new ParserField($post); + foreach ($this->rif as $key => $v) + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . $dbfields->parse($this->rif[$key]); + } + + + if ($coppie != "") { + $query = "UPDATE riferimento SET " . strip_tags($coppie) . " WHERE ri_id=" . $this->rif["ri_id"]->value; + $result = $_SESSION['db']->execute($query); + return $result; + } + + return TRUE; + } + + public function aggiornaDB() { + + $coppie = ""; + + foreach ($this->rif as $key => $v) { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . ParserField::quote($this->rif[$key]); + } + + + if ($coppie != "") { + $query = "UPDATE riferimento SET " . strip_tags($coppie) . " WHERE ri_id=" . $this->rif["ri_id"]->value; + $result = $_SESSION['db']->execute($query); + return $result; + } + + return TRUE; + } + + public function aggiornaObject($post) { + $noinsert = unserialize(urldecode($post["noins_rif"])); + $flds = new ParserField($post); + foreach ($this->rif as $key => $v) { + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + $value = $flds->simple_parse($this->rif[$key]); + $this->rif[$key]->value = $value; + } + } + if (isset($post['ri_docID'])) + $_SESSION['ri_docID'] = $post['ri_docID']; + return TRUE; + } + function parse_openurl($type) { + $oR = new OpenResolver(); + $infoAutori = array(); + if (isset($_GET['sid']) && urldecode($_GET['sid']) == 'Entrez:PubMed' && isset($_GET['id']) && strpos(urldecode($_GET['id']), "pmid:") === 0) { + + $valori = $oR->parser_Pubmed(urldecode($_GET['id']), urldecode($_GET['sid'])); + $infoAutori = preg_split("/,/", $valori['autore'], 2); + if (!isset($infoAutori[1])) + $infoAutori[1] = ""; + list($autore1, $altriautori) = $infoAutori; + $this->rif["ri_titolopub"]->value = isset($valori['titolo']) ? $valori['titolo'] : null; + $this->rif["ri_titolopart"]->value = isset($valori['sottotitolo']) ? $valori['sottotitolo'] : null; + $this->rif["ri_au1"]->value = $autore1; + $this->rif["ri_au2"]->value = $altriautori; + $this->rif["ri_anno"]->value = isset($valori['anno']) ? $valori['anno'] : null; + $this->rif["ri_vol"]->value = isset($valori['volume']) ? $valori['volume'] : null; + $this->rif["ri_fasc"]->value = isset($valori['fascicolo']) ? $valori['fascicolo'] : null; + $this->rif["ri_pgini"]->value = isset($valori['pagini']) ? $valori['pagini'] : null; + $this->rif["ri_pgfine"]->value = isset($valori['pagfin']) ? $valori['pagfin'] : null; + $this->rif["ri_editore"]->value = isset($valori['editore']) ? $valori['editore'] : null; + $this->rif["ri_luogoed"]->value = isset($valori['luogo']) ? $valori['luogo'] : null; + $this->rif["ri_issn"]->value = isset($valori['issn']) ? $valori['issn'] : null; + $this->rif["ri_abstract"]->value = isset($valori['abstract']) ? $valori['abstract'] : null; + $this->rif["ri_sid"]->value = $_GET['sid']; + $this->rif["ri_doi"]->value = isset($valori['doi']) ? $valori['doi'] : null; + $this->rif["ri_pmid"]->value = isset($valori['pmid']) ? $valori['pmid'] : null; + }else { + $genericdata = $oR->getGenericData(); + $titoli = $oR->getTitle(); + $autori = $oR->getAuthor(); + $codice = $oR->getISSNISBN(); + $this->rif["ri_titolopub"]->value = isset($titoli['titolo']) ? $titoli['titolo'] : null; + $this->rif["ri_titolopart"]->value = isset($titoli['sottotitolo']) ? $titoli['sottotitolo'] : null; + $this->rif["ri_au1"]->value = isset($autori[0]) ? $autori[0] : null; + $this->rif["ri_au2"]->value = isset($autori[1]) ? $autori[1] : null; + $this->rif["ri_anno"]->value = isset($genericdata['anno']) ? $genericdata['anno'] : null; + $this->rif["ri_vol"]->value = isset($genericdata['volume']) ? $genericdata['volume'] : null; + $this->rif["ri_pgini"]->value = isset($genericdata['pagini']) ? $genericdata['pagini'] : null; + $this->rif["ri_pgfine"]->value = isset($genericdata['pagfin']) ? $genericdata['pagfin'] : null; + $this->rif["ri_editore"]->value = isset($genericdata['editore']) ? $genericdata['editore'] : null; + $this->rif["ri_luogoed"]->value = isset($genericdata['luogo']) ? $genericdata['luogo'] : null; + $this->rif["ri_sid"]->value = $oR->getSID(); + + $this->rif["ri_doi"]->value = $oR->getdoi(); + if ($type == getConstVar("TIPO_ARTICOLO")) { + $this->rif["ri_fasc"]->value = $genericdata['fascicolo']; + } + + if ($type == getConstVar("TIPO_ARTICOLO")) { + $this->rif["ri_issn"]->value = $codice['issn']; + } else { + $this->rif["ri_isbn"]->value = $codice['isbn']; + } + } + } + +// DIADOSIS TEAM Get details from DOI... + //the curl request processor + function processCurlJsonrequest($URL) { //Initiate cURL request and send back the result + $ch = curl_init(); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json')); + curl_setopt($ch, CURLOPT_URL, $URL); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + $resulta = curl_exec($ch); + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + + if (curl_errno($ch)) { + $return = curl_error($ch); + } else if ($contentType !== 'application/json') { + $return = false; + } else { + $return = $resulta; + curl_close($ch); + } + return $return; + } + +// DIADOSIS TEAM Get details from PMID... + //the curl request processor + function processCurlXMLrequest($URL) { //Initiate cURL request and send back the result + $ch = curl_init(); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml')); + curl_setopt($ch, CURLOPT_URL, $URL); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + $resulta = curl_exec($ch); + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + if (curl_errno($ch)) { + $return = curl_error($ch); + } else if ($contentType !== 'text/xml; charset=UTF-8') { + $return = false; + } else { + $return = $resulta; + curl_close($ch); + } + return $return; + } + +//DIADOSIS TEAM * Parse DOI + function parse_doi_api($type) { + if (isset($_GET['doi'])) { + $_GET['doi'] = strip_tags($_GET['doi']); + if (strpos($_GET['doi'], '10.') !== false) { + $doi = "https://dx.doi.org/" . $_GET['doi']; + $json_r = json_decode($this->processCurlJsonrequest($doi)); + +// DIADOSIS TEAM Check if api call with doi returns results, meaning id doi is published or if there was another problem + if (!is_null($json_r)) { + $i = 0; + $infoAutori = $json_r->author[0]->family . ' ' . $json_r->author[0]->given; + $infoAutori1 = ""; + + foreach ($json_r->author as $auth) { + if ($i != 0) { + $infoAutori1 .= $auth->family . ' ' . $auth->given . ", "; + } + $i++; + } + $infoAutori1 = substr($infoAutori1, 0, -2); + $this->rif["ri_titolopub"]->value = isset($json_r->{'container-title'}) ? $json_r->{'container-title'} : null; + $this->rif["ri_titolopart"]->value = isset($json_r->title) ? $json_r->title : null; + $this->rif["ri_au1"]->value = $infoAutori; + $this->rif["ri_au2"]->value = $infoAutori1; + $this->rif["ri_anno"]->value = isset($json_r->issued->{'date-parts'}[0]) ? $json_r->issued->{'date-parts'}[0][0] : null; + $this->rif["ri_vol"]->value = isset($json_r->volume) ? $json_r->volume : null; + $this->rif["ri_fasc"]->value = isset($json_r->issue) ? $json_r->issue : null; + $pages = explode("-", $json_r->page); + $this->rif["ri_pgini"]->value = (isset($pages[0]) && $pages[0] != 0) ? $pages[0] : "1"; + $this->rif["ri_pgfine"]->value = isset($pages[1]) ? $pages[1] : "1"; + $this->rif["ri_editore"]->value = isset($json_r->publisher) ? $json_r->publisher : null; + $this->rif["ri_issn"]->value = isset($json_r->ISSN[0]) ? $json_r->ISSN[0] : null; + $this->rif["ri_abstract"]->value = isset($json_r->abstract) ? $json_r->abstract : null; + $this->rif["ri_sid"]->value = $_GET['sid']; + $this->rif["ri_doi"]->value = isset($json_r->DOI) ? $json_r->DOI : null; + } else { + echo ''; + $this->rif["ri_titolopub"]->value = "DOI: " . $_GET['doi']; + $this->rif["ri_anno"]->value = date("Y"); + $this->rif["ri_pgini"]->value = "1"; + $this->rif["ri_doi"]->value = $_GET['doi']; + } + } else { + $doi = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=" . $_GET['doi']; + $xml_r = simplexml_load_string($this->processCurlXMLrequest($doi)); +// DIADOSIS TEAM Check if api call with pmid returns results, meaning pmid was not correct or if there was another problem + if (isset($xml_r->ERROR) || !isset($xml_r->PubmedArticle)) { + echo ''; + $this->rif["ri_pmid"]->value = $_GET['doi']; + } else { + $i = 0; + $infoAutori = $xml_r->PubmedArticle->MedlineCitation->Article->AuthorList->Author->LastName[0] . ' ' . $xml_r->PubmedArticle->MedlineCitation->Article->AuthorList->Author->ForeName[0] . ' ' . $xml_r->PubmedArticle->MedlineCitation->Article->AuthorList->Author->Initials[0]; + $infoAutori1 = ""; + + foreach ($xml_r->PubmedArticle->MedlineCitation->Article->AuthorList->Author as $auth) { + if ($i != 0) { + $infoAutori1 .= $auth->LastName . ' ' . $auth->ForeName . ' ' . $auth->Initials . ", "; + } + $i++; + } + +// DIADOSIS TEAM GET article DOI and PMID from list of IDs. if PMID not in list get it from above field in the api result + foreach ($xml_r->PubmedArticle->PubmedData->ArticleIdList->ArticleId as $ids) { + if ($ids ["IdType"] == "doi") + $api_get_doi = (string) $ids[0]; + if ($ids ["IdType"] == "pubmed") + $api_get_pmid = (string) $ids[0]; + } + if (!isset($api_get_pmid)) + $api_get_pmid = $xml_r->PubmedArticle->MedlineCitation->PMID; + + if (isset($xml_r->PubmedArticle->MedlineCitation->Article->Pagination)) { + $pages = explode("-", $xml_r->PubmedArticle->MedlineCitation->Article->Pagination->MedlinePgn); + $pages[1] = $pages[0] + $pages[1]; + } + + if (isset($xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->PubDate->Year)) + $year = (string) $xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->PubDate->Year; + else + if (isset($xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->PubDate->MedlineDate)) + $year = substr((string) $xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->PubDate->MedlineDate, 0, 4); + else + $year = "0"; + + $infoAutori1 = substr($infoAutori1, 0, -2); + $this->rif["ri_titolopub"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->Journal->Title) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->Journal->Title : null; + $this->rif["ri_titolopart"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->ArticleTitle) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->ArticleTitle : null; + $this->rif["ri_au1"]->value = $infoAutori; + $this->rif["ri_au2"]->value = $infoAutori1; + $this->rif["ri_anno"]->value = $year; + $this->rif["ri_vol"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->Volume) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->Volume : null; + $this->rif["ri_fasc"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->Issue) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->Journal->JournalIssue->Issue : null; + $this->rif["ri_pgini"]->value = (isset($pages) && (int) $pages[0] != 0 ) ? $pages[0] : "1"; + $this->rif["ri_pgfine"]->value = (isset($pages) && (int) $pages[1] != 0 ) ? $pages[1] : "1"; + $this->rif["ri_editore"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->Abstract->CopyrightInformation) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->Abstract->CopyrightInformation : null; + $this->rif["ri_issn"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->Journal->ISSN) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->Journal->ISSN : null; + $this->rif["ri_abstract"]->value = isset($xml_r->PubmedArticle->MedlineCitation->Article->Abstract->AbstractText) ? (string) $xml_r->PubmedArticle->MedlineCitation->Article->Abstract->AbstractText : null; + $this->rif["ri_sid"]->value = $_GET['sid']; + $this->rif["ri_doi"]->value = isset($api_get_doi) ? $api_get_doi : null; + $this->rif["ri_pmid"]->value = $api_get_pmid; + } + } + } + } + +} diff --git a/modules/uploader.php b/modules/uploader.php new file mode 100644 index 0000000..4e85499 --- /dev/null +++ b/modules/uploader.php @@ -0,0 +1,169 @@ +getSize()){ + return false; + } + $target = fopen($path, "w"); + fseek($temp, 0, SEEK_SET); + stream_copy_to_stream($temp, $target); + fclose($target); + return true; + } + function getName() { + return $_GET['qqfile']; + } + function getSize() { + if (isset($_SERVER["CONTENT_LENGTH"])){ + return (int)$_SERVER["CONTENT_LENGTH"]; + } else { + throw new Exception('Getting content length is not supported.'); + } + } + } + + class qqUploadedFileForm { + function save($path) { + if(!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)){ + return false; + } + return true; + } + function getName() { + return $_FILES['qqfile']['name']; + } + function getSize() { + return $_FILES['qqfile']['size']; + } + } + + class qqFileUploader { + private $allowedExtensions = array(); + private $sizeLimit = 31457280; + private $file; + private $newfilename; + + + function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){ + $allowedExtensions = array_map("strtolower", $allowedExtensions); + $this->newfilename=null; + if(isset($_REQUEST["fname"])) + $this->newfilename=$_REQUEST["fname"]; + $this->allowedExtensions = $allowedExtensions; + $this->sizeLimit = $sizeLimit; + $this->checkServerSettings(); + if (isset($_GET['qqfile'])) { + $this->file = new qqUploadedFileXhr(); + } elseif (isset($_FILES['qqfile'])) { + $this->file = new qqUploadedFileForm(); + } else { + $this->file = false; + } + } + + private function checkServerSettings(){ + $postSize = $this->toBytes(ini_get('post_max_size')); + $uploadSize = $this->toBytes(ini_get('upload_max_filesize')); + if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit){ + $size = max(1, $this->sizeLimit / 1024 / 1024) . 'M'; + die("{'error':'increase post_max_size and upload_max_filesize to $size'}"); + } + } + + private function toBytes($str){ + $val = trim($str); + $last = strtolower($str[strlen($str)-1]); + switch($last) { + case 'g': $val *= 1024; + case 'm': $val *= 1024; + case 'k': $val *= 1024; + } + return $val; + } + + public function getFile() + { + return $this->file; + } + + function handleUpload($uploadDirectory, $replaceOldFile = FALSE,$backupdir=null){ + if (!is_writable($uploadDirectory)){ + return array('error' => "Server error. Upload directory isn't writable."); + } + + if (!$this->file){ + return array('error' => 'No files were uploaded.'); + } + + $size = $this->file->getSize(); + + + if ($size == 0) { + return array('error' => getConstVar('ERR_UPLOAD_EMPTY_FILE')); + } + + if ($size > $this->sizeLimit) { + return array('error' => getConstVar('ERR_UPLOAD_FILESIZE')); + } + + $pathinfo = pathinfo($this->file->getName()); + $filename = $pathinfo['filename']; + //$filename = md5(uniqid()); + $ext = $pathinfo['extension']; + + if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ + $these = implode(', ', $this->allowedExtensions); + return array('error' => getConstVar('ERR_UPLOAD_NO_ALLOWED_EXTENSION'). $these . '.'); + } + + if(!$replaceOldFile){ + while (file_exists($uploadDirectory . $filename . '.' . $ext)) { + $filename .= rand(10, 99); + } + } + + $final_fname=$filename; + if($this->newfilename!=null) + { + $final_fname=$this->newfilename; + if(!$replaceOldFile){ + while (file_exists($uploadDirectory . $final_fname . '.' . $ext)) { + $final_fname .= "_".rand(10, 99); + } + } + } + + $final_fname=strtolower($final_fname.".".$ext); + + if ($this->file->save($uploadDirectory . $final_fname)) + { + if($backupdir!=null && strtolower($ext)=="pdf") + { + $dest=$backupdir.$final_fname; + copy($uploadDirectory.$final_fname, $dest); + } + return array('success'=>true,'filename'=>$final_fname); + } else { + return array('error'=> 'Could not save uploaded file.' . + 'The upload was cancelled, or server error encountered'); + } + + + } + } + + include_once("utility.php"); + include_once("session_header.php"); + $allowedExtensions = getConstVar("ALLOWED_EXTENSIONS"); + $sizeLimit = getConstVar('MAX_FILESIZE'); + $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); + $result = $uploader->handleUpload(getConstVar('UPLOAD_DIR'),TRUE,null); + echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); + +?> \ No newline at end of file diff --git a/modules/utente.php b/modules/utente.php new file mode 100755 index 0000000..f5dd44e --- /dev/null +++ b/modules/utente.php @@ -0,0 +1,1136 @@ +ute = $_SESSION['db']->fetch_fields("utente"); + $this->ute["ut_pwd_2"] = clone $this->ute["ut_pwd"]; + $this->ute["ut_pwd_2"]->fieldname = "ut_pwd_2"; + $this->reset_controllo(); + $this->reset_idbib(); + if ($id != null) { + $result = $_SESSION['db']->execute("SELECT * FROM utente WHERE ut_id=$id"); + if ($result && $_SESSION['db']->numrows($result) == 1) { + $dati = $_SESSION['db']->fetch($result); + foreach ($this->ute as $key => $v) { + if ($key != 'ut_pwd_2') + $this->ute[$key]->value = $dati[$key]; + } + } + } + $this->person_identity_fields = array($this->ute["ut_usr"], $this->ute["ut_pwd"], $this->ute["ut_pwd_2"], $this->ute["ut_nome"], $this->ute["ut_cognome"], $this->ute["qu_id"], $this->ute["ut_dip"], $this->ute["ut_mat"], $this->ute["ut_referente"], $this->ute["ut_preflang"], $this->ute["ut_mothertongue"]); + $this->person_contacts_fields = array($this->ute["ut_email"], $this->ute["ut_tel_1"], $this->ute["ut_tel_2"], $this->ute["ut_fax"], $this->ute["ut_skype"]); + $this->person_identity_fields_myusers = array($this->ute["ut_nome"], $this->ute["ut_cognome"], $this->ute["qu_id"], $this->ute["ut_dip"], $this->ute["ut_mat"], $this->ute["ut_referente"]); + } + + public function __get($fieldname) { + return $this->ute[$fieldname]->value; + } + + public function getnome() { + return $this->ute["ut_nome"]->value; + } + + public function __set($fieldname, $value) { + $this->ute[$fieldname]->value = $value; + } + + public function __isset($fieldname) { + return isset($this->ute[$fieldname]); + } + + public function __unset($fieldname) { + unset($this->ute[$fieldname]); + } + + function __toString() { + return $this->ute["ut_nome"]->value; + } + + public function get_controllo() { + return $this->controllo; + } + + public function set_idbib($val) { + $this->idbib = $val; + } + + public function get_idbib() { + return $this->idbib; + } + + public function reset_idbib() { + $this->idbib = null; + } + + public function reset_controllo() { + $this->controllo = array(); + } + + function visualizza($action = "action_utente.php") { + $form = new FieldsForm("form_utente", "javascript:editAccount('$action')"); + $form->addHidden("ut_id", $this->ute["ut_id"]->value); + $form->addHidden("op", "edit"); + $form->addHTML($this->visualizza_identity()); + $form->addHTML($this->visualizza_contacts()); + $form->close(); + return $form->restituisci(); + } + + function visualizza_popup() { + $tel1 = $this->ut_tel_1 != null ? "
" . getConstVar("ut_tel_1") . ": " . $this->ut_tel_1 : null; + $tel2 = $this->ut_tel_2 != null ? "
" . getConstVar("ut_tel_2") . ": " . $this->ut_tel_2 : null; + $fax = $this->ut_fax != null ? "
" . getConstVar("ut_fax") . ": " . $this->ut_fax : null; + $mail = $this->ut_email != null ? "
" . getConstVar("ut_email") . ": " . $this->ut_email : null; + echo "" . $this->ut_cognome . " " . $this->ut_nome . "" . $mail . $tel1 . $tel2 . $fax; + } + + function visualizza_myusers($bi_id) { + $form = new FieldsForm("form_utente", "javascript:editAccount()"); + $form->addHidden("ut_id", $this->ute["ut_id"]->value); + $form->addHidden("op", "edit"); + $form->addHTML($this->visualizza_tools($bi_id)); + $form->addHTML($this->visualizza_identity_myusers()); + $form->addHTML($this->visualizza_contacts()); + $form->close(); + return $form->restituisci(); + } + + private function visualizza_identity($registrazione = FALSE) { + $html = "
"; + foreach ($this->person_identity_fields as $key => $v) { + if (!(LoginSession::isShibUserLogged() && (($this->person_identity_fields[$key]->fieldname == "ut_usr") || + ($this->person_identity_fields[$key]->fieldname == "ut_pwd") || + ($this->person_identity_fields[$key]->fieldname == "ut_pwd_2") ) + )) { + if ($this->person_identity_fields[$key]->fieldname != "ut_pwd" && $this->person_identity_fields[$key]->fieldname != "ut_pwd_2") { + $var = $this->person_identity_fields[$key]; + $html.=FieldRender::renderField($var); + } else if ($this->person_identity_fields[$key]->fieldname == "ut_pwd") { + $html.="
"; + $html.="" . getConstVar("ut_pwd") . ": " . getConstVar("CHOOSED_PWD") . ""; + $html.="
\n"; + } + } + } + $html.="
"; + return $html; + } + + private function visualizza_identity_myusers() { + $html = "
"; + foreach ($this->person_identity_fields_myusers as $key => $v) { + $var = $this->person_identity_fields_myusers[$key]; + $html.=FieldRender::renderField($var); + } + $html.="
"; + return $html; + } + + private function visualizza_contacts($registrazione = FALSE) { + if ($registrazione) + $html = "
"; + else + $html = "
"; + foreach ($this->person_contacts_fields as $key => $v) { + $var = $this->person_contacts_fields[$key]; + $html.=FieldRender::renderField($var); + } + $html.="
"; + return $html; + } + + public function visualizza_tools($id_bib) { + $ret = "
"; + $status = $_SESSION['db']->execute("SELECT ap_stato FROM appartiene WHERE ut_id=" . $this->ute["ut_id"]->value . " AND bi_id=$id_bib"); + $ap_stato = -1; + if ($_SESSION['db']->numrows($status) == 1) { + $ap_stato = $_SESSION['db']->fetch_single($status); + if ($ap_stato == getConstVar("UTENTE_IN_ATTESA")) { + $ret.="ute["ut_id"]->value . ",'disabilita')\" id=\"disable_user\">" . getConstVar("DISABLE") . ""; + $ret.="ute["ut_id"]->value . ",'abilita')\" id=\"enable_user\">" . getConstVar("ENABLE") . ""; + } else if ($ap_stato == getConstVar("UTENTE_ABILITATO")) + $ret.="ute["ut_id"]->value . ",'disabilita')\" id=\"disable_user\">" . getConstVar("DISABLE") . ""; + else if ($ap_stato == getConstVar("UTENTE_DISABILITATO_DD")) { + $ret.="ute["ut_id"]->value . ")\" id=\"delete_user\">" . getConstVar("DELETE") . ""; + $ret.="ute["ut_id"]->value . ",'abilita')\" id=\"re-enable_user\">" . getConstVar("ENABLE") . ""; + } + } + $ret.="
"; + return $ret; + } + + public function registra($step) { + $this->reset_controllo(); + $res = ""; + $lazySessionURL = getShibLoginURL(getConstVar("HTTPROOTDIRSHIB") . "/shibauth.php"); + switch ($step) { + + case "1": + $res.=" +
+
+
+
+
+
+
+
+
+
+
"; + $res.=printNavBar("registration_user"); + $res.="
+
+
+
+
"; + $res.=getConstVar("REG_UTE"); + $res.="
+
+
+
+ "; + $res.=$this->reg_nav($step); + $res.=" +
+
+ "; + $res.="
"; + $sel = ""; + if (isset($_SESSION["normalreg"]) && $_SESSION["normalreg"] == 1) + $sel = "checked=checked"; + $res.="
"; + $res.=$this->reg_passo($step); + + $res.=" +
+
+
+
+
+
+
+
+
+
+
+
+
+ "; + break; + + case "Shib2": + + $res.=" +
+
+
+
+
+
+
+
+
+
+
"; + $res.=printNavBar("registration_user"); + $res.="
+
+
+
+
"; + $res.=getConstVar("REG_UTE"); + $res.="
+
+
"; + $res.=$this->reg_passo($step); + $res.=" +
+
+
+
+
+
+
+
+
+
+
+
+
+ "; + break; + + + case "4": + $res.=" +
+
+
+
+
+
+
+
+
+
+
"; + + $res.=printNavBar("registration_user"); + $res.="
+
+
+
+
"; + $res.=getConstVar("REG_UTE"); + $res.="
+
+
+ "; + $res.=$this->reg_passo($step); + + $res.=" +
+ "; + if (LoginSession::isShibUserLogged()) { + $res.=$this->reg_notifica($step, TRUE); + } else { + $res.=$this->reg_notifica($step); + } + + $res.=" +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ "; + break; + + default: + $res.="
"; + if (LoginSession::isShibUserLogged()) { + $res.=$this->reg_nav($step, 2); + $res.=$this->reg_notifica($step, TRUE); + } else { + $res.=$this->reg_nav($step); + $res.=$this->reg_notifica($step); + } + $res.=" +
+ +
+
+
+
+
+
+
+
+
+
+
"; + $res.=printNavBar("registration_user"); + $res.="
+
+
+
+
"; + $res.=getConstVar("REG_UTE"); + $res.="
+
+
+ "; + + $res.=$this->reg_passo($step); + + $res.=" +
+
+
+
+
+
+
+
+
+
+
+
+
+ "; + + break; + } + + return $res; + } + + public function reg_notifica($step, $shib = FALSE) { + + switch ($step) { + + case "2": + $html = "
"; + $html.=FieldRender::renderField($this->ute["ut_usr"]); + $html.="
"; + $html.=" " . getConstVar("ut_pwd") . ": " . getConstVar("CHOOSED_PWD") . ""; + $html.="
\n"; + $html.="
\n"; + return $html; + break; + + case "3": + $html = ""; + if (!$shib) { + $html.="
"; + $html.=FieldRender::renderField($this->ute["ut_usr"]); + $html.="
"; + $html.=" " . getConstVar("ut_pwd") . ": " . getConstVar("CHOOSED_PWD") . ""; + $html.="
\n"; + $html.="
\n"; + } + $html.="
"; + $html.=" " . getConstVar("bi_nome") . ": " . nome_biblio($this->idbib) . " "; + $html.="
\n"; + return $html; + break; + + + case "4": + $html = ""; + $html.=$this->visualizza_identity(TRUE); + $html.="
"; + $html.="
"; + $html.=" " . getConstVar("bi_nome") . ": " . nome_biblio($this->idbib) . " "; + $html.="
\n"; + $html.="
\n"; + $html.=$this->visualizza_contacts(TRUE); + return $html; + break; + } + } + + public function reg_passo($step) { + $visible = ""; + $this->reset_controllo(); + switch ($step) { + case "Shib2": + $passo = "
"; + + $form = new FieldsForm("form_reg_ute", "", "onkeypress=\"return disabilitaTasti(event)\""); + + $res_ute = $_SESSION['db']->execute("SELECT ut_id FROM utente WHERE ut_eptid='" . $_SESSION['shibbData']->getShibValue('Shib-TargetedID') . "'"); + if ($res_ute && $_SESSION['db']->numrows($res_ute) == 1) { + $form->addHtml("

" . getConstVar("REG_UTE_SHIB_ALREADY_EXIST") . "



< " . getConstVar("BACK_TO2") . " Home"); + $form->close(); + $passo.=$form->restituisci(); + } else { + $query = " SELECT bi_id,bi_nome + FROM biblio + WHERE + bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") + AND biblio.en_id = ( SELECT en_id + FROM idp WHERE idp_url = \"" . $_SESSION['shibbData']->getShibValue("Shib-Identity-Provider") . "\") + ORDER BY bi_nome + "; + $result = $_SESSION['db']->execute($query); + $numbib = $_SESSION['db']->numrows($result); + if ($this->idbib != null) { + $form->addHTML("
" . getConstVar("bi_nome") . ": " . nome_biblio($this->idbib) . "

"); + $form->addHTML("
"); + } else { + + if ($numbib == 0) + $form->addHtml("

" . getConstVar("REG_UTE_SHIB_NO_BIBLIO") . "



< " . getConstVar("BACK_TO2") . " Home"); + else { + $form->addHtml("
"); + $form->addHTML("
+ $form->addHTML("
"); + while ($row = $_SESSION['db']->fetch($result)) + $form->addHTML("" . $row["bi_nome"] . "
"); + + $form->addHTML("
+ "); + + $this->controllo["idbib"]["obbligo"] = 1; + } + } + $form->addHTML($this->reg_buttons(2, 1)); +// DIADOSIS TEAM Auto click when logged in via shibboleth and does not have to choose a library + $form->addHTML(""); + $form->close(); + $passo.=$form->restituisci(); + } + break; + + case "1": + + if (!isset($_SESSION["normalreg"])) + $visible = ""; + else if ($_SESSION["normalreg"] == 1) + $visible = ""; + $passo = "
"; + + $form = new FieldsForm("form_reg_ute", ""); + $form->addHtml(" +
+

+
" . getConstVar("REG_UTE_SEL_CRED") . "
" . getConstVar("REG_UTE_SEL_CRED_2") . "
+

+
+ "); + $cont_tmp = $form->addField($this->ute["ut_usr"], null, null, null, null, 1); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHtml("\n\n
"); + $cont_tmp = $form->addField($this->ute["ut_pwd"], null, null, null, null, 1); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $form->addHtml("\n\n
"); + $cont_tmp = $form->addField($this->ute["ut_pwd_2"], null, null, null, null, 1); + $this->controllo = array_merge($this->controllo, $cont_tmp); + $tosave["ut_usr"] = TRUE; + $tosave["ut_pwd"] = TRUE; + $tosave["ut_pwd_2"] = TRUE; + $code = urlencode(serialize($tosave)); + $form->addHidden("savekeys", $code); + $form->addHTML($this->reg_buttons($step)); + $form->addHTML("
"); + + $form->close(); + $passo.=$form->restituisci(); + break; + + + + case "2": + $passo = "
"; + $_SESSION["normalreg"] = 1; + + $form = new FieldsForm("form_reg_ute", "", "onkeypress=\"return disabilitaTasti(event)\""); + $form->addHtml("
+
+

+ " . getConstVar("REG_UTE_SEL_BIB") . " +

+
+ "); + $nation_arr = db_elenco("na_id"); + + $default_nation = "GRE"; + if ($this->idbib != null) { + $result_na = $_SESSION['db']->execute("SELECT na_id FROM biblio WHERE bi_id=" . $this->idbib); + if ($result_na && $_SESSION['db']->numrows($result_na) == 1) + $default_nation = $_SESSION['db']->fetch_single($result_na); + } + $form->addHTML("
" . getConstVar("na_id") . ":
"); + $cont_tmp = $form->addSelect("na_id", null, $nation_arr, $default_nation, 6, "onchange=\"javascript:updateNation()\"", "", ""); + $form->addHTML("
"); + + if ($this->idbib != null) { + $form->addHTML("
" . getConstVar("bi_nome") . ": " . nome_biblio($this->idbib) . "

"); + $form->addButton("btn_change", getConstVar("CHANGE_LIB"), "onclick=\"javascript:change_library()\"", null, "\n"); + $form->addHTML("
"); + + $form->addHTML($this->reg_buttons($step)); + } else { + $form->addHTML(db_search_library($default_nation)); + $form->addHTML($this->reg_buttons($step)); + $this->controllo["idbib"]["obbligo"] = 1; + } + $form->close(); + $passo.=$form->restituisci(); + break; + + case "3": + $passo = "
"; + $form = new FieldsForm("form_reg_ute", ""); + $form->addHtml("
+
+

+ " . getConstVar("REG_UTE_SEL_DATI") . " +

+
+ "); + + $primo_qu[''] = getConstVar("OPTION_FIRST_LINE"); + $qual_arr = db_elenco('qu_id', 'bi_id = ' . $this->idbib); + if (count($qual_arr) > 0) + $qual_arr = $primo_qu + $qual_arr; + else + $qual_arr = $primo_qu; + + $primo_dip['0'] = getConstVar('SENZA_DIP'); + $dip_arr = db_elenco('dip_id', 'bi_id = ' . $this->idbib . " AND dip_stato=1"); + if (count($dip_arr) > 0) + $dip_arr = $primo_dip + $dip_arr; + else + $dip_arr = $primo_dip; + $query1 = "SELECT dip_id FROM idp WHERE idp_url = \"" . $_SESSION['shibbData']->getShibValue("Shib-Identity-Provider") . "\""; + $result1 = $_SESSION['db']->execute($query1); + $data1 = $_SESSION['db']->fetch($result1); + $dip_id_db = intval($data1["dip_id"]); + + $query2 = "SELECT qu_id FROM t_qualifica WHERE qualifica = \"" . $_SESSION['shibbData']->getShibValue("Shib-affiliation") . "\""; + $result2 = $_SESSION['db']->execute($query2); + $data2 = $_SESSION['db']->fetch($result2); + $qu_id_db = intval($data2["qu_id"]); + + foreach ($this->ute as $key => $v) + if ($key != "ut_id" && $key != "ut_usr" && $key != "ut_pwd" && $key != "ut_pwd_2" && $key != "ut_eptid" && $key != "ut_data_reg") { + switch ($key) { + case 'qu_id': + if (is_array($data2)) { + $inp = false; + foreach ($qual_arr as $qu_id => $qu_nome) { + if ($qu_id === $qu_id_db) { + $inp = true; + $qual_one_arr = array($qu_id => $qu_nome); + $cont_tmp = $form->addFieldSelect($this->ute["qu_id"], null, $qual_one_arr, null, "style=\"display: none;\""); + } + } + } else + $cont_tmp = $form->addFieldSelect($this->ute["qu_id"], FALSE, $qual_arr); + break; + case 'ut_preflang': $cont_tmp = $form->addFieldSelect($this->ute["ut_preflang"], FALSE, getSupportedLanguages()); + break; + case 'ut_mothertongue': $cont_tmp = $form->addFieldSelect($this->ute["ut_mothertongue"], FALSE, getSupportedLanguages()); + break; + case 'ut_dip': + if (is_array($data1)) { + $inp = false; + foreach ($dip_arr as $dip_id => $dip_nome) { + if ($dip_id === $dip_id_db) { + $inp = true; + $dip_one_arr = array($dip_id => $dip_nome); + $cont_tmp = $form->addFieldSelect($this->ute["ut_dip"], null, $dip_one_arr, null, "style=\"display: none;\""); + } + } + } else + $cont_tmp = $form->addFieldSelect($this->ute["ut_dip"], null, $dip_arr, null); + break; + + default: $cont_tmp = $form->addField($this->ute[$key]); + break; + } + $this->controllo = array_merge($this->controllo, $cont_tmp); + $tosave[$key] = TRUE; + } + $code = urlencode(serialize($tosave)); + $form->addHTML("
" . getConstVar("REG_USER_READ_LEGAL_NOTICE") . "" . getConstVar("LEGAL_NOTICE") . "

"); + $form->addHidden("savekeys", $code); + if (LoginSession::isShibUserLogged()) + $form->addHTML($this->reg_buttons($step, 1)); + else + $form->addHTML($this->reg_buttons($step)); + + $form->addHTML("
"); + $form->addHTML("
"); + + $form->close(); + $passo.=$form->restituisci(); + break; + + case "4": + break; + } + + $passo.="
+
+ "; + return $passo; + } + + public function reg_buttons($step, $shib = 0) { + $button = ""; + $button.=getConstVar("REQUIRED_FIELDS"); + if (1 < $step && !($step == 2 && $shib == 1)) { + if ($step == 3 && $shib == 1) + $prev = "Shib2"; + else + $prev = $step - 1; +// DIADOSIS TEAM If previous step auto select library via shib login then do not display back button + if ($prev != "Shib2") + $button.= " + \"\" + + " . getConstVar("INDIETRO") . " + + \"\" + + "; + } + + $next = $step + 1; + if ($step == 2 && $shib == 1) + $button.= " + "; + else + $button.= " + \"\" + + " . getConstVar("PROSEGUI") . " + + \"\" + + "; + + return $button; + } + + public function reg_nav($step, $start = 1) { + $nav = "
"; + $end = 4; + if ($start != 1) { + $step = $step - $start + 1; + $end = $end - $start + 1; + } + + for ($i = 1; $i <= $end; $i++) { + if ($i != 1) { + if ($i <= $step) + $nav.= "
"; + else + $nav.= ""; + } + if ($i <= $step) + $nav.= "
" . $i . "
"; + else + $nav.= "
" . $i . "
"; + } + $nav.= "
"; + return $nav; + } + + public function set_parse($fieldname, $post) { + $flds = new ParserField($post); + $value = $flds->simple_parse($this->ute[$fieldname]); + $this->ute[$fieldname]->value = $value; + } + + + public function aggiornaObject($post) { + foreach ($this->controllo as $key => $v) { + if (isset($this->ute[$key])) { + $this->ute[$key]->value = isset($post[$key]) ? $post[$key] : null; + } + } + if (isset($post["idbib"])) + $this->idbib = $post["idbib"]; + return TRUE; + } + + public function ShibDataUpdate($shibbData) { + $this->ute["ut_eptid"]->value = $shibbData->getShibValue("Shib-TargetedID"); + $this->ute["ut_nome"]->value = $shibbData->getShibValue("givenName"); + $this->ute["ut_cognome"]->value = $shibbData->getShibValue("sn"); + $this->ute["ut_email"]->value = $shibbData->getShibValue("mail"); + $this->ute["ut_preflang"]->value = $shibbData->getShibValue("preferredLanguage"); + $this->ute["ut_mothertongue"]->value = $shibbData->getShibValue("motherTongue"); + $arrayTelNum = array(); + $arrayTelNum = preg_split("/ /", $shibbData->getShibValue("telephoneNumber")); + $this->ute["ut_tel_1"]->value = build_phone((isset($arrayTelNum[0]) ? $arrayTelNum[0] : null) . (isset($arrayTelNum[1]) ? $arrayTelNum[1] : null), (isset($arrayTelNum[2]) ? $arrayTelNum[2] : null)); + $arrayTelMobile = array(); + $arrayTelMobile = preg_split("/ /", $shibbData->getShibValue("mobile")); + $this->ute["ut_tel_2"]->value = build_phone((isset($arrayTelMobile[0]) ? $arrayTelMobile[0] : null) . (isset($arrayTelMobile[1]) ? $arrayTelMobile[1] : null), (isset($arrayTelNum[2]) ? $arrayTelNum[2] : null)); + $contact = array(); + $contact = preg_split("/;/", $shibbData->getShibValue("schacUserPresenceID")); + $skype = ""; + foreach ($contact as $con) { + if (strpos($con, "skype") !== FALSE) + $skype = preg_replace('/^skype\:/', '', $con); + } + $this->ute["ut_skype"]->value = $skype; + + $query = " SELECT qualifica.qu_id + FROM qualifica,t_qualifica + WHERE qualifica.qu_id=t_qualifica.qu_id AND t_qualifica.lang_id='" . $_SESSION["lang"] . "' AND t_qualifica.qualifica LIKE(\"" . $shibbData->getShibValue("title") . "\")"; + $result = $_SESSION['db']->execute($query); + $qualifica = $_SESSION['db']->fetch_single($result); + if ($qualifica != null) + $this->ute["qu_id"]->value = $qualifica; + + return TRUE; + } + + function parseandsave($post) { + global $ute; + $tosave = unserialize(urldecode($post["savekeys"])); + $dbfields = new ParserField($post); + foreach ($this->ute as $key => $v) { + if ($tosave[$key]) { + $this->ute[$key]->value = $dbfields->simple_parse($this->ute[$key]); + $ute->$key = $this->ute[$key]->value; + } + } + } + + function nuovo($action = "action_utente.php") { + $this->form($action, TRUE); + } + + function modifica($action = "action_utente.php") { + $this->ute["ut_pwd"]->value = ""; + $this->ute["ut_pwd_2"]->value = ""; + + $this->ute["ut_pwd"]->isnull = TRUE; + $this->ute["ut_pwd_2"]->isnull = TRUE; + + $this->form($action, FALSE); + } + + function elimina() { + $query_1 = " + SELECT COUNT(ut_id) + FROM refman + WHERE rm_stato <> " . getConstVar("Rif_NonRichiesto") . " and ut_id = " . $this->ute["ut_id"]->value; + $result1 = $_SESSION['db']->execute($query_1); + $ordini = $_SESSION['db']->fetch_single($result1); + if ($ordini == 0) { + $query_2a = " + DELETE FROM riferimento + WHERE ri_id = any ( + SELECT ri_id + FROM refman + WHERE ut_id = " . $this->ute["ut_id"]->value . ")"; + + $query_2b = " + DELETE FROM utente + WHERE ut_id = " . $this->ute["ut_id"]->value; + + $result_2a = $_SESSION['db']->execute($query_2a); + $result_2b = $_SESSION['db']->execute($query_2b); + } else { + $query_3 = " + SELECT COUNT(ri_id) + FROM refman + WHERE rm_stato = " . getConstVar("Rif_RichiestaAperta") . " AND ut_id = " . $this->ute["ut_id"]->value; + + $result_3 = $_SESSION['db']->execute($query_3); + $row = $_SESSION['db']->fetch($result_3, 2); + $ordini_ap = $row[0]; + + if ($ordini_ap != 0) + echo "ATTENZIONE - impossibile effettuare l'eliminazione, l'utente ha ancora " . $ordini_ap . " ordini in attesa."; + else { + $query_4 = " + UPDATE appartiene + SET ap_stato = " . getConstVar("UTENTE_ELIMINATO_BIBLIO") . " + WHERE ut_id = " . $this->ute["ut_id"]->value; + + $result_4 = $_SESSION['db']->execute($query_4); + } + } + } + + public function delete($biid) { + $query = "UPDATE appartiene SET ap_stato=" . getConstVar("UTENTE_ELIMINATO_BIBLIO") . " WHERE ut_id=" . $this->ute["ut_id"]->value . " AND bi_id=$biid"; + $result = $_SESSION['db']->execute($query); + if ($result) + return 1; + else + return 0; + + } + + function form($action, $new = FALSE) { + $controllo = array(); + $form = new FieldsForm("form_utente", "javascript:editAccount('$action')"); + if (!$new) { + $form->addHidden("ut_id", $this->ute["ut_id"]->value, null, "\n"); + $form->addHidden("op", "update", null, "\n"); + } else { + $form->addHidden("op", "new", null, "\n"); + $biblio_arr = db_elenco("bi_id"); + $form->addSelect("idbib", FALSE, $biblio_arr, null, 1, null, "Biblioteca di appartenenza:", "
\n"); + } + $form->addHTML("
"); + foreach ($this->person_identity_fields as $k => $v) { + if (!(LoginSession::isShibUserLogged() && (($this->person_identity_fields[$k]->fieldname == "ut_usr") || + ($this->person_identity_fields[$k]->fieldname == "ut_pwd") || + ($this->person_identity_fields[$k]->fieldname == "ut_pwd_2") ) + )) { + $var = $this->person_identity_fields[$k]; + $key = $var->fieldname; + $result = $_SESSION['db']->execute("SELECT bi_id FROM appartiene WHERE ut_id = $this->ut_id"); + $bib_id_ute = $_SESSION['db']->fetch_single($result); + + if ($key == "qu_id") { + $primo_qual[""] = getConstVar("OPTION_FIRST_LINE"); + $qual_arr = db_elenco('qu_id', "bi_id = $bib_id_ute"); + if (count($qual_arr) > 0) + $qual_arr = $primo_qual + $qual_arr; + else + $qual_arr = $primo_qual; + $controllo = array_merge($controllo, $form->addFieldSelect($this->ute[$key], FALSE, $qual_arr)); + } else if ($key == "ut_dip") { + $primo_dip['0'] = getConstVar('SENZA_DIP'); + $dip_arr = db_elenco('dip_id', "bi_id = $bib_id_ute AND dip_stato=1"); + if (count($dip_arr) > 0) + $dip_arr = $primo_dip + $dip_arr; + else + $dip_arr = $primo_dip; + + $form->addFieldSelect($this->ute[$key], FALSE, $dip_arr); + } + else if ($key == "ut_preflang" || $key == "ut_mothertongue") { + $form->addFieldSelect($this->ute[$key], FALSE, getSupportedLanguages()); + } else { + if ($key != "ut_id" && ($key != "ut_usr" || $new)) { + $controllo_person_identity = $form->addField($this->ute[$key]); + $controllo = array_merge($controllo, $controllo_person_identity); + } else + $noinsert[$key] = TRUE; + } + } + } + $noinsert["ut_pwd_2"] = TRUE; + + $form->addHTML("
"); + + $form->addHTML("
"); + foreach ($this->person_contacts_fields as $k => $v) { + $var = $this->person_contacts_fields[$k]; + $key = $var->fieldname; + $controllo_person_contacts = $form->addField($this->ute[$key]); + $controllo = array_merge($controllo, $controllo_person_contacts); + } + + $form->addButton("save_btn", getConstVar("SAVE"), "class=\"submit\" onclick=\"javascript:salva_account()\""); + $form->addHTML("  "); + $form->addButton("cancel_btn", getConstVar("CANCEL"), "class=\"submit\" onclick=\"javascript:undo_account_edit()\""); + $form->addHTML(getConstVar("REQUIRED_FIELDS")); + $form->addHTML("
"); + $code_noinsert = urlencode(serialize($noinsert)); + $form->addHidden("noins", $code_noinsert); + $code_controllo = urlencode(serialize($controllo)); + $form->addHidden("controllo", $code_controllo); + $form->close(); + $form->stampa(); + } + + function inserisci() { + $idute = null; + $attributi = ""; + $valori = ""; + foreach ($this->ute as $key => $v) + if ($key != "ut_id" && $key != "ut_pwd_2") { + $val = ParserField::quote($this->ute[$key]); + if ($attributi != "") + $attributi.=","; + if ($valori != "") + $valori.=","; + $attributi.=$key; + $valori.=$val; + } + if ($attributi != "") { + $query_1 = " + INSERT INTO utente ($attributi) + VALUES ($valori); "; + $result_1 = $_SESSION['db']->execute($query_1); + $idute = $_SESSION['db']->last_id(); + if ($idute != null) { + $query_2 = " + INSERT INTO appartiene (bi_id,ut_id,ap_stato) + VALUES (" . $this->idbib . ",$idute,'1')"; + + $result_2 = $_SESSION['db']->execute($query_2); + } + } + return $idute; + } + + public function aggiorna($post) { + + $coppie = ""; + + $noinsert = unserialize(urldecode($post["noins"])); + + if (isset($post['ut_nome'])) + $post['ut_nome'] = ucwords(strtolower($post['ut_nome'])); + if (isset($post['ut_cognome'])) + $post['ut_cognome'] = ucwords(strtolower($post['ut_cognome'])); + if (isset($post['ut_referente'])) + $post['ut_referente'] = ucwords(strtolower($post['ut_referente'])); + + $dbfields = new ParserField($post); + + if (!LoginSession::isShibUserLogged()) { + if ($post["ut_pwd"] != "" && $post["ut_pwd"] != NULL && $post["ut_pwd"] == $post["ut_pwd_2"]) + $coppie.="ut_pwd=" . $dbfields->parse($this->ute["ut_pwd"]); + else + $noinsert["ut_pwd"] = TRUE; + } + else { + $noinsert["ut_pwd"] = TRUE; + $noinsert["ut_usr"] = TRUE; + $noinsert["ut_eptid"] = TRUE; + } + + foreach ($this->ute as $key => $v) { + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + if ($coppie != "") + $coppie.=","; + $coppie.=$key . "=" . $dbfields->parse($this->ute[$key]); + } + } + if ($coppie != "") { + $query = "UPDATE utente SET $coppie WHERE ut_id=" . $this->ute["ut_id"]->value; + $result = $_SESSION['db']->execute($query); + if (!$result) + return false; + } + return true; + } + + public function visualizza_biblioteche() { + $result = $_SESSION['db']->execute( + "SELECT biblio.bi_id, bi_nome, bi_tel, bi_sospini, bi_sospfine,bi_referente_dd,bi_email_dd,bi_referente_ill,bi_email_ill,ap_stato + FROM appartiene,biblio + WHERE appartiene.ut_id=" . $this->ute["ut_id"]->value . " AND appartiene.bi_id=biblio.bi_id ORDER BY bi_nome" + ); + $cols = $_SESSION['db']->numcols($result); + for ($j = 0; $j < $cols; $j++) + $flds[$j] = $_SESSION['db']->fieldname($result, $j); + + if ($_SESSION['db']->numrows($result) > 0) { + while ($row = $_SESSION['db']->fetch($result)) { + print ("
"); + for ($j = 0; $j < $cols; $j++) { + if ($flds[$j] != "bi_id" && $flds[$j] != "ap_stato") + if ($flds[$j] == "bi_sospini" && $row[$flds[$j]] != NULL) + echo "Προσοχή: Αναστολή της υπηρεσίας από " . $row[$flds[$j]]; + else if ($flds[$j] == "bi_sospfine" && $row[$flds[$j]] != NULL) + echo " έως " . $row[$flds[$j]]; + else + echo FieldRender::render($flds[$j], $row[$flds[$j]]); + } + if (isset($_SESSION['from3to4']) && !$_SESSION['from3to4'] && in_array($row['ap_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) + print "
______________________________________
" . getConstVar('AVVISO_UTENTE_DISABILITATO_DD'); + print("
"); + } + } + else { + print (getConstVar("NO_LIBRARY")); + } + } + + function controlla_campi($post) { + $lista = null; + $pf = new ParserField($post); + $noinsert = unserialize(urldecode($post["noins"])); + foreach ($this->ute as $key => $v) { + if (!isset($noinsert[$key]) || !$noinsert[$key]) { + $vv = $pf->simple_parse($this->ute[$key]); + if (!$this->ute[$key]->isnull && isset($vv) && ($vv == "" || $vv == "NULL")) { + if ($lista != "" && $lista != null) + $lista.=" "; + + $k = $key; + if (strpos($key, "_tel") || strpos($key, "_fax")) { + $k.=" " . $key . Form::$pref . " " . $key . Form::$numero; + } + $lista.=$k; + } else if ($key == "ut_pwd") { + if ($post["ut_pwd"] == "" && $post["ut_pwd_2"] != "") + $lista.="ut_pwd"; + else if ($post["ut_pwd"] != "" && $post["ut_pwd_2"] == "") + $lista.="ut_pwd_2"; + } + } + } + return $lista; + } + + function controlla_campi_reg($post) { + + $lista = null; + $pf = new ParserField($post); + + $tocontrol = unserialize(urldecode($post["savekeys"])); + + foreach ($this->ute as $key => $v) { + if ($tocontrol[$key]) { + $vv = $pf->simple_parse($this->ute[$key]); + if (!$this->ute[$key]->isnull && isset($vv) && ($vv == "" || $vv == "NULL")) { + if ($lista != "" && $lista != null) + $lista.=" "; + + $k = $key; + if (strpos($key, "_tel") || strpos($key, "_fax")) { + $k.=" " . $key . Form::$pref . " " . $key . Form::$numero; + } + + $lista.=$k; + } else if ($key == "ut_pwd") { + if ($post["ut_pwd"] == "" && $post["ut_pwd_2"] != "") + $lista.="ut_pwd"; + else if ($post["ut_pwd"] != "" && $post["ut_pwd_2"] == "") + $lista.="ut_pwd_2"; + } + } + } + + return $lista; + } + + public function control_usr($user) { + $result = $_SESSION['db']->execute("SELECT COUNT(ut_id) FROM utente WHERE ut_usr='$user'"); + $n_user = $_SESSION['db']->fetch_single($result); + if ($n_user == 0) + return TRUE; + else + return FALSE; + } + + public function conferma_pwd($post) { + + if ($_POST["ut_pwd"] == $_POST["ut_pwd_2"]) + return null; + else + return "ut_pwd ut_pwd_2"; + } + + public function cambia_stato($bibid, $stato) { + $query = "UPDATE appartiene SET ap_stato=$stato WHERE ut_id=" . $this->ute["ut_id"]->value . " AND bi_id=$bibid"; + $result = $_SESSION['db']->execute($query); + } + +} + +?> diff --git a/mynilde_users_account_mgr.php b/mynilde_users_account_mgr.php new file mode 100755 index 0000000..101fd14 --- /dev/null +++ b/mynilde_users_account_mgr.php @@ -0,0 +1,106 @@ +
+
+ +
+ "; + else + echo ""; + + + $nome="".$_SESSION['utente']->ut_nome." ".$_SESSION['utente']->ut_cognome.""; + echo "
$WELCOME $nome
"; + } + ?> +
+
+ '; + else + echo '
    '; + + if(checkSospensioneDD(date("Y-m-d"),array('bi_sospini' => $date_presospini,'bi_sospfine' => $sospdate['bi_sospfine']))){ + echo "
  • ".getConstVar('MSG_SOSPENSIONE_DD')." ".getConstVar('DAL')." ".print_date($sospdate["bi_sospini"])." ". getConstVar('AL_TIME')." ".print_date($sospdate["bi_sospfine"])."
  • "; + } + if (!$_SESSION['from3to4'] && isset($_SESSION['app_stato']) && in_array($_SESSION['app_stato'], getConstVar('UTENTE_ACL_DD_DENY'))) + { + echo "
  • ".getConstVar('AVVISO_UTENTE_DISABILITATO_DD')."
  • "; + } + if(!biblioIsActive($_SESSION['bib_app'])){ + echo "
  • ".getConstVar('MSG_SOSPENSIONE_DD')."
  • "; + } + + if(getConstVar('SONDAGGIO_ATTIVO')==1) + echo "
  • ".getConstVar('SONDAGGIO_USERS_MSG')."
  • "; + + + + echo '
'; + ?> + + +
+
\ No newline at end of file diff --git a/nilde_library_history.php b/nilde_library_history.php new file mode 100755 index 0000000..6b4a741 --- /dev/null +++ b/nilde_library_history.php @@ -0,0 +1,59 @@ +
+
+
+
+
+ +
+
+ Here goes the loading clip. +
+
+ + +
+
+
+ +
+
+
+
+
+ +
+
 
+
+ addRadio("tipo", "2", false, "onclick=\"javascript:changeHistorySearch(2)\"", null, "" . getConstVar("HISTORYDD_USERTYPE") . "", null); + $form->addRadio("tipo", "3", false, "onclick=\"javascript:changeHistorySearch(3)\"", null, "" . getConstVar("HISTORYDD_IDTYPE") . "", null); + $form->addHTML("
"); + $ret = ""; + $form->addHTML("
"); + $form->close(); + $form->stampa(); + ?> + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/public_header.php b/public_header.php new file mode 100755 index 0000000..52e6e9f --- /dev/null +++ b/public_header.php @@ -0,0 +1,7 @@ +
+ + +
+ \ No newline at end of file diff --git a/reports.php b/reports.php new file mode 100755 index 0000000..51e81a7 --- /dev/null +++ b/reports.php @@ -0,0 +1,2281 @@ +" . getConstVar("REPORTS_GRAPH_GLOBALE1A") . " -  + " . getConstVar("REPORTS_GRAPH_GLOBALE1E") . " -  + " . getConstVar("REPORTS_GRAPH_GLOBALE1C") . " -  + " . getConstVar("REPORTS_GRAPH_GLOBALE1D") . ""; + return $ret; + break; + + case "report_biblioteca": + $ret = "" . getConstVar("REPORTS_GRAPH_BIBLIO2A") . " -  + " . getConstVar("REPORTS_GRAPH_RIEPILOGO") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2D") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2E") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2F") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2G") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2H") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2I") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2L") . " -  + " . getConstVar("REPORTS_GRAPH_BIBLIO2M") . ""; + return $ret; + break; + + case "report_utenti": + $ret = "" . getConstVar("REPORTS_GRAPH_UTENTE3A") . " -  + " . getConstVar("REPORTS_GRAPH_UTENTE3B") . " -  + " . getConstVar("REPORTS_GRAPH_UTENTE3M") . " -  + " . getConstVar("REPORTS_GRAPH_UTENTE3H") . " -  + " . getConstVar("REPORTS_GRAPH_UTENTE3L") . " -  + " . getConstVar("REPORTS_GRAPH_UTENTE3G") . " -  + " . getConstVar("REPORTS_GRAPH_UTENTE3I") . ""; + return $ret; + break; + case "export": + $ret = ""; + $ret.= "" . getConstVar("EXPORT_BIBLIO") . " - "; + $ret.= "" . getConstVar("REPORTS_GRAPH_ENTE") . " - "; + $ret.= "" . getConstVar("REPORTS_GRAPH_PROJECT") . ""; + return $ret; + break; + } +} + +function print_tagimg($gr) { + $temp_file = tempnam(sys_get_temp_dir(), 'img'); + $gr->Stroke($temp_file); + $fp = fopen($temp_file, "r"); + $bytes = filesize($temp_file); + $buffer = fread($fp, $bytes); + fclose($fp); + @unlink($temp_file); + + $base = base64_encode($buffer); + $code = "

"; + return $code; +} + +function cutstring($stringa) { + if (strlen($stringa) > 40) { + $s = substr_replace($stringa, "\n", strlen($stringa) / 2, 0); + } else { + $s = $stringa; + } + return $s; +} + +function print_graph($typegraph, $year = null, $report_order = null, $report_qualif = null) { + $ret = ""; + + switch ($typegraph) { + + case 'scambi_globali_year': + $result = $_SESSION['db']->execute("SELECT SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel)+ SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) as tot_rich,re_anno FROM report_biblio WHERE re_anno>=2011 GROUP BY re_anno ORDER BY re_anno ASC"); + $assex = array("2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010"); + $data = array(16988, 56081, 86465, 101250, 114425, 123150, 139020, 159571); + + $ret = ""; + if ($_SESSION['db']->numrows($result) != 0) { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tot_rich']; + $assex[] = $row['re_anno']; + } + $graph = new Graph(500, 300); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NETWORK_TOT_SCAMBI")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->SetScale('textint'); + $graph->ygrid->Show(false); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $bplot = new BarPlot($data); + $bplot->SetFillColor("bisque3"); + $bplot->value->Show(); + $bplot->value->SetFormat('%01.0f'); + $graph->Add($bplot); + $graph->xaxis->SetTickLabels($assex); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("ANNI")); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case 'tempo_risp': + $result = $_SESSION['db']->execute("SELECT AVG(re_tempo_risp_bw)/86400 as tasso,re_anno FROM report_biblio WHERE re_anno>=2011 GROUP BY re_anno ORDER BY re_anno ASC"); + $assex = array("2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010"); + $data = array(3.5, 2.63, 1.81, 1.85, 1.44, 1.08, 1.03, 0.95); + + $ret = ""; + if ($_SESSION['db']->numrows($result) != 0) { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tasso']; + $assex[] = $row['re_anno']; + } + $graph = new Graph(500, 300); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NETWORK_AVG_GIACENZA")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->SetScale('textint'); + $graph->ygrid->Show(false); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $bplot = new LinePlot($data); + $bplot->SetFillColor("white"); + $bplot->mark->SetType(MARK_FILLEDCIRCLE); + $bplot->mark->SetFillColor("red"); + $bplot->mark->SetWidth(4); + $bplot->value->Show(); + $graph->Add($bplot); + $graph->xaxis->SetTickLabels($assex); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("ANNI")); + $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->yaxis->title->Set(getConstVar("DAYS")); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case 'distr_tipoente': + $result = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot,t_tipoente.tipoente AS ente FROM `biblio` LEFT JOIN ente ON biblio.en_id=ente.en_id LEFT JOIN tipoente ON ente.ti_id=tipoente.ti_id LEFT join t_tipoente ON t_tipoente.ti_id=tipoente.ti_id AND lang_id='" . $_SESSION['lang'] . "' WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") GROUP BY ente"); + $data = array(); + $datalegend = array(); + $ret = ""; + if ($_SESSION['db']->numrows($result) != 0) { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tot']; + $datalegend[] = "(" . $row['tot'] . ") " . $row['ente']; + } + + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->title->Set(getConstVar("NET_DISTRBIB_IST")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + } + return $ret; + break; + case 'distr_cataloghi': + $ret = ""; + $res_acnp = $_SESSION['db']->execute("SELECT COUNT( tab_acnp.bi_id ) AS tot + FROM tab_acnp, biblio_catalogo, biblio + WHERE biblio_catalogo.bi_id = tab_acnp.bi_id + AND biblio_catalogo.ca_id =1 + AND bc_attivo =1 + AND biblio.bi_id = biblio_catalogo.bi_id + AND bi_nilde =1 + AND biblio.na_id = 'ITA' + AND acnp_attivo IN (0,1,2) + AND bi_stato + IN ( " . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ")"); + $res_acnp_attivo = $_SESSION['db']->execute("SELECT COUNT( tab_acnp.bi_id ) AS tot + FROM tab_acnp, biblio_catalogo, biblio + WHERE biblio_catalogo.bi_id = tab_acnp.bi_id + AND biblio_catalogo.ca_id =1 + AND bc_attivo =1 + AND biblio.bi_id = biblio_catalogo.bi_id + AND bi_nilde =1 + AND biblio.na_id = 'ITA' + AND acnp_attivo=1 + AND bi_stato + IN ( " . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ")"); + + $res_mai = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM `biblio_catalogo` LEFT JOIN catalogo ON catalogo.ca_id=biblio_catalogo.ca_id WHERE bc_attivo=1 AND biblio_catalogo.ca_id=3 AND bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") )"); + $res_sbn = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM `biblio_catalogo` LEFT JOIN catalogo ON catalogo.ca_id=biblio_catalogo.ca_id WHERE bc_attivo=1 AND biblio_catalogo.ca_id=2 AND bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") )"); + $res_rebiun = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM `biblio_catalogo` LEFT JOIN catalogo ON catalogo.ca_id=biblio_catalogo.ca_id WHERE bc_attivo=1 AND biblio_catalogo.ca_id=5 AND bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") )"); + $res_altre = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND bi_id not IN (SELECT distinct(bi_id) from biblio_catalogo WHERE bc_attivo=1)"); + + $tot_acnp = $_SESSION['db']->fetch_single($res_acnp_attivo); + $tot_sbn = $_SESSION['db']->fetch_single($res_sbn); + $tot_mai = $_SESSION['db']->fetch_single($res_mai); + $tot_altre = $_SESSION['db']->fetch_single($res_altre); + $tot_rebiun = $_SESSION['db']->fetch_single($res_rebiun); + + $ca_array = array(); + $cat_res = $_SESSION['db']->execute("SELECT ca_id,ca_nome from catalogo"); + + while ($c = $_SESSION['db']->fetch($cat_res)) { + $key = $c["ca_id"]; + $v = $c["ca_nome"]; + $ca_array[$key] = $v; + } + + $data = array(); + $data[] = $tot_acnp; + $data[] = $tot_sbn; + $data[] = $tot_mai; + $data[] = $tot_rebiun; + $data[] = $tot_altre; + $assex[] = $ca_array['1']; + $assex[] = $ca_array['2']; + $assex[] = $ca_array['3']; + $assex[] = $ca_array['5']; + getConstVar("REBIUN"); + $assex[] = getConstVar("OTHERS"); + $graph = new Graph(500, 300); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NET_DISTRBIB_CATNAZIONALI")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->SetScale('textint'); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $bplot = new BarPlot($data); + $color = getConstVar("GRAPH_COLOR_LIST"); + $bplot->SetFillColor($color); + $bplot->value->Show(); + $bplot->value->SetFormat('%01.0f'); + $graph->Add($bplot); + $graph->xaxis->SetTickLabels($assex); + $ret.= print_tagimg($graph); + + return $ret; + break; + + case "pie_multidisciplina": + + $result = $_SESSION['db']->execute("SELECT t_disciplina.disciplina AS nome, COUNT(biblio.di_id) AS tot FROM biblio,disciplina,t_disciplina WHERE disciplina.di_id=t_disciplina.di_id AND t_disciplina.lang_id='" . $_SESSION["lang"] . "' AND biblio.di_id=disciplina.di_id AND bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") GROUP BY nome"); + $data = array(); + $datalegend = array(); + $ret = ""; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tot']; + $datalegend[] = "(" . $row['tot'] . ") " . $row['nome']; + } + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NET_DISTRBIB_DISCIPLINE")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + } + return $ret; + break; + case "distr_nazione": + $result = $_SESSION['db']->execute("SELECT count(bi_id) as tot, biblio.na_id,na_nome from biblio,nazione where biblio.na_id=nazione.na_id AND bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") group by biblio.na_id"); + $data = array(); + $datalegend = array(); + $ret = ""; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tot']; + $datalegend[] = "(" . $row['tot'] . ") " . $row['na_id'] . " - " . $row['na_nome']; + } + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NET_DISTRBIB_NAZIONE")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case 'distr_ute_tipoente': + $result = $_SESSION['db']->execute("SELECT COUNT(ut_id) as tot, TE.tipoente as nometipo FROM appartiene as APP, biblio AS B, ente AS E, tipoente AS T,t_tipoente AS TE WHERE TE.ti_id=T.ti_id AND TE.lang_id='" . $_SESSION['lang'] . "' AND APP.ap_stato=1 AND APP.bi_id=B.bi_id AND B.en_id=E.en_id AND E.ti_id=T.ti_id AND B.bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") ) GROUP BY TE.tipoente"); + $data = array(); + $datalegend = array(); + $ret = ""; + if ($_SESSION['db']->numrows($result) != 0) { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tot']; + $datalegend[] = "(" . $row['tot'] . ") " . $row['nometipo']; + } + + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NET_DISTRUTE_IST")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case 'distr_ute_multidisciplina': + $result = $_SESSION['db']->execute("SELECT COUNT(ut_id) as tot,TD.disciplina as discip FROM appartiene as APP, biblio AS B, disciplina D,t_disciplina TD WHERE TD.di_id=D.di_id AND TD.lang_id='" . $_SESSION['lang'] . "' AND APP.ap_stato=1 AND APP.bi_id=B.bi_id AND B.di_id=D.di_id AND B.bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") ) GROUP BY TD.disciplina"); + $data = array(); + $datalegend = array(); + $ret = ""; + if ($_SESSION['db']->numrows($result) != 0) { + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row['tot']; + $datalegend[] = "(" . $row['tot'] . ") " . $row['discip']; + } + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->title->Set(getConstVar("NET_DISTRUTE_DISCIP")); + $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + + + case "globale1A": + $result = $_SESSION['db']->execute("SELECT SUM(re_evase_dir)+SUM(re_evase_nilde)+SUM(re_inevase_nilde)+SUM(re_inevase_dir) as borrowing, SUM(re_evase_dir)+SUM(re_evase_nilde) as lending, re_anno FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno HAVING (borrowing > 0 OR lending > 0 )ORDER BY re_anno ASC "); + $data_rich = array(); + $data_forn = array(); + $assex = array(); + while ($row = $_SESSION['db']->fetch($result)) { + $data_rich[] = $row["borrowing"]; + $data_forn[] = $row["lending"]; + $assex[] = $row["re_anno"]; + } + $ret .= "

" . getConstVar("REPORTS_GRAPHTITLE_GLOBALE1A") . "


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale('textint'); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'top', 'left'); + $b1plot = new BarPlot($data_rich); + $b1plot->SetFillColor(getConstVar("GRAPH_BAR1COLOR")); + $b1plot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI")); + $b1plot->value->SetFormat('%01.0f'); + $b1plot->value->Show(); + $b2plot = new BarPlot($data_forn); + $b2plot->SetFillColor(getConstVar("GRAPH_BAR2COLOR")); + $b2plot->SetLegend(getConstVar("REPORTS_ART_FORNITI")); + $b2plot->value->SetFormat('%01.0f'); + $b2plot->value->Show(); + $gbplot = new GroupBarPlot(array($b1plot, $b2plot)); + $graph->Add($gbplot); + $graph->xaxis->SetTickLabels($assex); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("ANNI")); + $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->yaxis->title->Set(getConstVar("REPORTS_NUM_RICHIE")); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case "globale1B": + + $result = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_ricev) as ricevuti + FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY rv HAVING ricevuti>0 ORDER BY ricevuti DESC LIMIT 20"); + $result1 = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_forni) as forniti + FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY rv HAVING forniti>0 ORDER BY forniti DESC LIMIT 20"); + $data_rich = array(); + $data_forn = array(); + $assex = array(); + $assexf = array(); + $a = array(); + $array_nomi = array(); + $array_nomif = array(); + + while ($row = $_SESSION['db']->fetch($result)) { + $data_rich[] = $row["ricevuti"]; //borrowing + $assex[] = $row["rv"]; + } + while ($row = $_SESSION['db']->fetch($result1)) { + $data_forn[] = $row["forniti"]; //lending + $assexf[] = $row["rv"]; + } + $array_nomi = array_map("cutstring", $assex); + $array_nomif = array_map("cutstring", $assexf); + $ret.= "

" . getConstVar("REPORTS_GRAPHTITLE_GLOBALE1B") . " " . date("Y", strtotime($_SESSION['biblio']->bi_data_reg)) . "


"; + if ($_SESSION['db']->numrows($result) == 0 && $_SESSION['db']->numrows($result1) == 0) + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + else { + if ($_SESSION['db']->numrows($result) != 0) { + + $graph = new Graph(800, 600); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale('textint'); + $graph->Set90AndMargin(250, 50, 80, 30); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'top', 'left'); + $graph->xaxis->SetTickLabels($array_nomi); + $graph->xaxis->SetFont(FF_DV_SERIF, FS_NORMAL, 8); + $graph->xaxis->SetLabelMargin(10); + $graph->xaxis->SetLabelAlign('right', 'center'); + $bplot = new BarPlot($data_rich); + $bplot->SetFillColor(getConstVar("GRAPH_BAR1COLOR")); + $bplot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI")); + $bplot->value->Show(); + $bplot->value->SetFormat('%01.0f'); + $bplot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 8); + $bplot->value->SetAlign('left', 'center'); + $bplot->value->SetColor('black', 'darkred'); + $graph->Add($bplot); + $ret.= print_tagimg($graph); + } + if ($_SESSION['db']->numrows($result1) != 0) { + $graph1 = new Graph(800, 600); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph1->SetScale('textint'); + $graph1->Set90AndMargin(250, 50, 80, 30); + $graph1->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph1->legend->SetLayout(LEGEND_HOR); + $graph1->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph1->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph1->legend->Pos(0.05, 0.01, 'top', 'left'); + $graph1->xaxis->SetTickLabels($array_nomif); + $graph1->xaxis->SetFont(FF_DV_SERIF, FS_NORMAL, 8); + $graph1->xaxis->SetLabelMargin(10); + $graph1->xaxis->SetLabelAlign('right', 'center'); + $b2plot = new BarPlot($data_forn); + $b2plot->SetFillColor(getConstVar("GRAPH_BAR2COLOR")); + $b2plot->SetLegend(getConstVar("REPORTS_ART_FORNITI")); + $b2plot->value->Show(); + $b2plot->value->SetFormat('%01.0f'); + $b2plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 8); + $b2plot->value->SetAlign('left', 'center'); + $b2plot->value->SetColor('black', 'darkred'); + $graph1->Add($b2plot); + $ret.= print_tagimg($graph1); + } + } + + return $ret; + break; + + case "globale1C": + $nameview = "view_" . rand(0, 999999); + $_SESSION['db']->execute("CREATE VIEW $nameview AS SELECT ut_id,SUM(re_richieste) as num_rich, re_anno FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY ut_id "); + $result1 = $_SESSION['db']->execute("SELECT AVG(num_rich) AS media, re_anno FROM $nameview GROUP BY re_anno "); + $_SESSION['db']->execute("DROP VIEW IF EXISTS $nameview"); + $data = array(); + $assex = array(); + $c = ""; + + $assex[0] = ''; + $data[0] = ''; + while ($row = $_SESSION['db']->fetch($result1)) { + $data[] = round($row["media"], 2); + $c = $assex[] = $row["re_anno"]; + } + + $ret.= "

" . getConstVar("REPORTS_GRAPH_GLOBALE1C") . " (" . getConstVar("AVG") . ")" . "


"; + if ($_SESSION['db']->numrows($result1) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale('intlin'); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'top', 'left'); + $lineplot = new LinePlot($data); + $lineplot->SetWeight(getConstVar("GRAPH_LINE_WIDTH")); + $lineplot->SetLegend(getConstVar("REPORTS_GRAPHLABEL_GLOBALE1C")); + $lineplot->value->SetFormat("%01.2f"); + $lineplot->value->Show(); + $lineplot->SetColor("red"); + $lineplot->mark->SetType(MARK_IMG_DIAMOND, 'red', 0.4); + $graph->Add($lineplot); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("ANNI")); + $graph->xaxis->SetTickLabels($assex); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case "globale1D": + $nameview = "view_" . rand(0, 999999); + $view = $_SESSION['db']->execute("CREATE VIEW $nameview AS SELECT ut_id,SUM(re_richieste) as re_richieste,re_anno FROM `report_utente` WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY ut_id"); + $result = $_SESSION['db']->execute("SELECT re_anno,SUM(CASE when re_richieste <=2 THEN 1 ELSE 0 END) as gruppo1,SUM(CASE when re_richieste >2 AND re_richieste <5 THEN 1 ELSE 0 END) as gruppo2,SUM(CASE when re_richieste >=5 AND re_richieste <=10 THEN 1 ELSE 0 END) as gruppo3,SUM(CASE when re_richieste >10 AND re_richieste <=20 THEN 1 ELSE 0 END) as gruppo4,SUM(CASE when re_richieste >20 AND re_richieste <=50 THEN 1 ELSE 0 END) as gruppo5,SUM(CASE when re_richieste > 50 AND re_richieste <=100 THEN 1 ELSE 0 END) as gruppo6,SUM(CASE when re_richieste >100 THEN 1 ELSE 0 END) as gruppo7 FROM $nameview GROUP by re_anno order by re_anno ASC"); + $data = array(); + $gruppo1 = array(); + $gruppo2 = array(); + $gruppo3 = array(); + $gruppo4 = array(); + $gruppo5 = array(); + $gruppo6 = array(); + $gruppo7 = array(); + $assex = array(); + $_SESSION['db']->execute("DROP VIEW IF EXISTS $nameview"); + while ($row = $_SESSION['db']->fetch($result)) { + $gruppo1[] = $row["gruppo1"]; + $gruppo2[] = $row["gruppo2"]; + $gruppo3[] = $row["gruppo3"]; + $gruppo4[] = $row["gruppo4"]; + $gruppo5[] = $row["gruppo5"]; + $gruppo6[] = $row["gruppo6"]; + $gruppo7[] = $row["gruppo7"]; + $assex[] = $row["re_anno"]; + } + $ret.= "

" . getConstVar("REPORTS_GRAPH_GLOBALE1D") . "


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale("textint"); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $b1plot = new BarPlot($gruppo1); + $b1plot->SetFillColor("bisque4"); + $b1plot->SetLegend("1 ή 2 " . getConstVar("REPORTS_RICHIESTE")); + $b2plot = new BarPlot($gruppo2); + $b2plot->SetFillColor("bisque"); + $b2plot->SetLegend(">2 " . getConstVar("REPORTS_RICHIESTE")); + $b3plot = new BarPlot($gruppo3); + $b3plot->SetFillColor("plum"); + $b3plot->SetLegend(">5 " . getConstVar("REPORTS_RICHIESTE")); + $b4plot = new BarPlot($gruppo4); + $b4plot->SetFillColor("thistle"); + $b4plot->SetLegend(">10 " . getConstVar("REPORTS_RICHIESTE")); + $b5plot = new BarPlot($gruppo5); + $b5plot->SetFillColor("cornflowerblue"); + $b5plot->SetLegend(">20 " . getConstVar("REPORTS_RICHIESTE")); + $b6plot = new BarPlot($gruppo6); + $b6plot->SetFillColor("lightpink"); + $b6plot->SetLegend(">50 " . getConstVar("REPORTS_RICHIESTE")); + $b7plot = new BarPlot($gruppo7); + $b7plot->SetFillColor("lightblue"); + $b7plot->SetLegend(">100 " . getConstVar("REPORTS_RICHIESTE")); + $gbplot = new AccBarPlot(array($b1plot, $b2plot, $b3plot, $b4plot, $b5plot, $b6plot, $b7plot)); + $graph->Add($gbplot); + $graph->legend->SetColumns(4); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'right', 'top'); + + $graph->xaxis->SetTickLabels($assex); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("ANNI")); + $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->yaxis->title->Set(getConstVar("REPORTS_NUM_UTENTI")); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case "globale1E": + $result = $_SESSION['db']->execute("SELECT YEAR(rm_datarichie) as re_anno, IFNULL(ROUND(AVG(UNIX_TIMESTAMP(STR_TO_DATE(dd_lastmodify, '%Y-%m-%d %H:%i:%s')) - UNIX_TIMESTAMP(STR_TO_DATE(rm_datarichie, '%Y-%m-%d %H:%i:%s')))/86400,3),0) as tempo_medio_L from docdel GROUP BY re_anno"); + $datay = array(); + $datay1 = array(); + $assex = array(); + $c = ""; + $assex[0] = ''; + $datay[0] = ''; + $datay1[0] = ''; + while ($row = $_SESSION['db']->fetch($result)) { + $datay[] = 0; + $datay1[] = $row["tempo_medio_L"]; + $c = $assex[] = $row["re_anno"]; + } + + $ret.= "

" . getConstVar("REPORTS_GRAPHTITLE_GLOBALE1E") . " (" . getConstVar("INDAYS") . ")" . "


"; + if ($_SESSION['db']->numrows($result) == 0 || (array_sum($datay) == 0 && array_sum($datay1) == 0)) { + $ret.= "
" . getConstVar("NOWORKTODOAVG") . "
"; + } else { + $graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale('intlin'); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'top', 'left'); + $lineplot = new LinePlot($datay); + $lineplot->SetWeight(getConstVar("GRAPH_LINE_WIDTH")); + $lineplot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI")); + $lineplot->value->SetFormat("%01.2f"); + $lineplot->value->Show(); + $lineplot->SetColor(getConstVar("GRAPH_BAR1COLOR")); + $lineplot->mark->SetType(MARK_IMG_DIAMOND, 'red', 0.4); + $graph->Add($lineplot); + $lineplot2 = new LinePlot($datay1); + $lineplot2->SetWeight(getConstVar("GRAPH_LINE_WIDTH")); + $lineplot2->SetLegend(getConstVar("REPORTS_ART_FORNITI")); + $lineplot2->value->SetFormat("%01.2f"); + $lineplot2->value->Show(); + $lineplot2->SetColor(getConstVar("GRAPH_BAR2COLOR")); + $lineplot2->mark->SetType(MARK_IMG_DIAMOND, 'blue', 0.4); + $graph->Add($lineplot2); + $graph->xaxis->SetTickLabels($assex); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("ANNI")); + $ret.= print_tagimg($graph); + } + return $ret; + break; + + case "biblio2A": + $result = $_SESSION['db']->execute("SELECT SUM(re_richieste_bw) as num_rich, SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel) as articoli_richiesti, SUM(re_richieste_ln) as rich_ln, SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel) AS articoli_forniti,SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) as inevasi_bw,SUM(re_inevaso_ln_riferr)+SUM(re_inevaso_ln_nonposs)+SUM(re_inevaso_ln_nondisp)+SUM(re_inevaso_ln_over15)+SUM(re_inevaso_ln_overquota)+SUM(re_inevaso_ln_altro) as inevasi_ln FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno = $year GROUP BY re_anno"); + $data = array(); + $assex = array(getConstVar("BORROWING"), getConstVar("LENDING")); + $ret.="

" . getConstVar("REPORTS_GRAPHTITLE_BIBLIO2A") . "


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + if ($_SESSION['db']->numrows($result) == 1) { + $row = $_SESSION['db']->fetch($result); + $dataT[] = $row["num_rich"]; + $dataT[] = $row["rich_ln"]; + $dataE[] = $row["articoli_richiesti"]; + $dataE[] = $row["articoli_forniti"]; + $dataI[] = $row["inevasi_bw"]; + $dataI[] = $row["inevasi_ln"]; + + if (array_sum($dataT) == 0 && array_sum($dataE) == 0 && array_sum($dataI) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale('textint'); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'top', 'left'); + $bplot = new BarPlot($dataT); + $bplot->SetFillColor("lightskyblue"); + $bplot->value->SetFormat('%01.0f'); + $bplot->value->Show(); + $bplot->SetLegend(getConstVar("REPORTS_ALLREQ")); + $b2plot = new BarPlot($dataE); + $b2plot->SetFillColor("seagreen"); + $b2plot->value->SetFormat('%01.0f'); + $b2plot->value->Show(); + $b2plot->SetLegend(getConstVar("REPORTS_REQ_EVASE")); + $b3plot = new BarPlot($dataI); + $b3plot->SetFillColor("tomato"); + $b3plot->value->SetFormat('%01.0f'); + $b3plot->value->Show(); + $b3plot->SetLegend(getConstVar("REPORTS_REQ_INEVASE")); + $gbplot = new GroupBarPlot(array($bplot, $b2plot, $b3plot)); + $graph->Add($gbplot); + $graph->xaxis->SetTickLabels($assex); + $ret.= print_tagimg($graph); + } + } + } + + return $ret; + break; + + case "riepilogo": + $result = $_SESSION['db']->execute("SELECT (SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel))/( SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel)+SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro)) as tasso_successo_bw, (SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel))/( SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel)+SUM(re_inevaso_ln_riferr)+SUM(re_inevaso_ln_nonposs)+SUM(re_inevaso_ln_nondisp)+SUM(re_inevaso_ln_over15)+SUM(re_inevaso_ln_overquota)+SUM(re_inevaso_ln_altro)) AS tasso_successo_ln FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno = $year GROUP BY re_anno"); + $result3 = $_SESSION['db']->execute("SELECT SUM(re_tempo_risp_bw)/SUM(re_richieste_bw)/86400 as media_giac_bw,SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as media_giac_ln FROM report_biblio where re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno"); + + $ret.= "

" . getConstVar("REPORTS_GRAPH_RIEPILOGO") . " " . getConstVar("NILDE_PLAIN") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 1) { + $tassi = $_SESSION['db']->fetch($result); + $tempi = $_SESSION['db']->fetch($result3); + $ret.= " "; + $ret.= " "; + $ret.= " "; + $ret.= " "; + $ret.= " "; + $ret.= " "; + $ret.= "
" . getConstVar("INDICATORE") . "" . getConstVar("VALORE") . "
" . getConstVar("REPORTS_GRAPH_RIEPILOGO_SB") . "" . (round($tassi["tasso_successo_bw"], 3) * 100) . "%
" . getConstVar("REPORTS_GRAPH_RIEPILOGO_SL") . "" . (round($tassi["tasso_successo_ln"], 3) * 100) . "%
" . getConstVar("REPORTS_GRAPH_RIEPILOGO_TB") . "" . round($tempi["media_giac_bw"], 2) . " " . getConstVar("DAYS") . "
" . getConstVar("REPORTS_GRAPH_RIEPILOGO_TL") . " " . round($tempi["media_giac_ln"], 2) . " " . getConstVar("DAYS") . "
"; + } else { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } + return $ret; + break; + + case "biblio2D": + $result = $_SESSION['db']->execute("SELECT SUM(re_evaso_bw_nilde) AS Nilde, SUM(re_evaso_bw_posta) AS Posta, SUM(re_evaso_bw_fax) AS Fax, SUM(re_evaso_bw_ariel) AS Ariel, SUM(re_evaso_bw_altro) AS Altro, SUM(re_evaso_bw_fn) AS FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno"); + $data = array(); + $tab = ""; + $ret.="

" . getConstVar("REPORTS_GRAPH_BIBLIO2D") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $i = 0; + $tabbody = ""; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["Nilde"]; + $data[] = $row["Posta"]; + $data[] = $row["Fax"]; + $data[] = $row["Ariel"]; + $data[] = $row["Altro"]; + $data[] = $row["FN"]; + + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["Nilde"] . " + " . $row["Posta"] . " + " . $row["Fax"] . " + " . $row["Ariel"] . " + " . $row["Altro"] . " + " . $row["FN"] . " + "; + $i++; + } + + $legend = array(getConstVar("NILDE_PLAIN"), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")), getConstVar("FN")); + + $datat[] = $legend; + $datat[] = $data; + if (array_sum($data) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($legend); + $graph->Add($p1); + $graph->legend->SetColumns(3); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("NILDE_PLAIN") . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")) . "" . getConstVar("FN") . "
"; + } + } + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "biblio2E": + $result = $_SESSION['db']->execute("SELECT SUM(re_inevaso_bw_riferr) as RifErrato, SUM(re_inevaso_bw_nonposs) as NonPoss, SUM(re_inevaso_bw_nondisp) as NonDisp, SUM(re_inevaso_bw_over15) as Over15, SUM(re_inevaso_bw_overquota) as OverQuota, SUM(re_inevaso_bw_altro) as Altro, SUM(re_inevaso_bw_fn) as FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno"); + $data = array(); + $tab = ""; + $ret.="

" . getConstVar("REPORTS_GRAPH_BIBLIO2E") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $i = 0; + $tabbody = ""; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["RifErrato"]; + $data[] = $row["NonPoss"]; + $data[] = $row["NonDisp"]; + $data[] = $row["Over15"]; + $data[] = $row["OverQuota"]; + $data[] = $row["Altro"]; + $data[] = $row["FN"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["RifErrato"] . " + " . $row["NonPoss"] . " + " . $row["NonDisp"] . " + " . $row["Over15"] . " + " . $row["OverQuota"] . " + " . $row["Altro"] . " + " . $row["FN"] . " + "; + $i++; + } + $legend = array(getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")), 'FN'); + $datat[] = $legend; + $datat[] = $data; + if (array_sum($data) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($legend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + + + + + + "; + + $tab.=$tabbody; + $tab.="
" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")) . "FN
"; + } + } + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "biblio2F": + $result = $_SESSION['db']->execute("SELECT SUM(re_evaso_ln_nilde) as Nilde, SUM(re_evaso_ln_posta) as Posta, SUM(re_evaso_ln_fax) as Fax, SUM(re_evaso_ln_ariel) as Ariel, SUM(re_evaso_ln_altro) as Altro,SUM(re_evaso_ln_fn) as FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno"); + $data = array(); + $datat = array(); + $tab = ""; + $ret.="

" . getConstVar("REPORTS_GRAPH_BIBLIO2F") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $i = 0; + $tabbody = ""; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["Nilde"]; + $data[] = $row["Posta"]; + $data[] = $row["Fax"]; + $data[] = $row["Ariel"]; + $data[] = $row["Altro"]; + $data[] = $row["FN"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["Nilde"] . " + " . $row["Posta"] . " + " . $row["Fax"] . " + " . $row["Ariel"] . " + " . $row["Altro"] . " + " . $row["FN"] . " + "; + $i++; + } + $legend = array(getConstVar("NILDE_PLAIN"), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")), getConstVar("FN")); + $datat[] = $legend; + $datat[] = $data; + if (array_sum($data) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($legend); + $graph->Add($p1); + $graph->legend->SetColumns(3); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + + + + + "; + + $tab.=$tabbody; + $tab.="
" . getConstVar("NILDE_PLAIN") . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")) . "" . getConstVar("FN") . "
"; + } + } + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "biblio2G": + $result = $_SESSION['db']->execute("SELECT SUM(re_inevaso_ln_riferr) as RifErrato, SUM(re_inevaso_ln_nonposs) as NonPoss, SUM(re_inevaso_ln_nondisp) as NonDisp, SUM(re_inevaso_ln_over15) as Over15, SUM(re_inevaso_ln_overquota) as OverQuota, SUM(re_inevaso_ln_altro) as Altro, SUM(re_inevaso_ln_fn) as FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno"); + $tab = ""; + $ret.="

" . getConstVar("REPORTS_GRAPH_BIBLIO2G") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $i = 0; + $tabbody = ""; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["RifErrato"]; + $data[] = $row["NonPoss"]; + $data[] = $row["NonDisp"]; + $data[] = $row["Over15"]; + $data[] = $row["OverQuota"]; + $data[] = $row["Altro"]; + $data[] = $row["FN"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["RifErrato"] . " + " . $row["NonPoss"] . " + " . $row["NonDisp"] . " + " . $row["Over15"] . " + " . $row["OverQuota"] . " + " . $row["Altro"] . " + " . $row["FN"] . " + "; + $i++; + } + $legend = array(getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")), 'FN'); + $datat[] = $legend; + $datat[] = $data; + if (array_sum($data) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($legend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")) . "" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")) . "FN
"; + } + } + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "biblio2H": + + if (!isset($report_order)) + $report_order = "bi_nome"; + $report_qualif = isset($report_qualif) ? $report_qualif : "asc"; + $ord = $report_order . " " . $report_qualif; + if ($report_order == "bi_nome") + $ord = "prov_id $report_qualif,$report_order $report_qualif"; + $result = $_SESSION['db']->execute("SELECT bi_nome, prov_id,rb.bi_idforni, SUM(re_richieste_bw) AS ordini_inviati, SUM(re_richieste_ln) AS ordini_ricevuti, SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_ariel)+SUM(re_evaso_bw_altro) AS art_ricevuti,SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro) AS art_forniti,(SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro))-(SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_ariel)+SUM(re_evaso_bw_altro)) AS diff_forni_ricev,SUM(re_richieste_bw_fn) AS ordini_fn_inviati, SUM(re_richieste_ln_fn) AS ordini_fn_ricevuti, SUM(re_evaso_bw_fn) AS art_fn_ricevuti, SUM(re_evaso_ln_fn) AS art_fn_forniti, (SUM(re_evaso_ln_fn))-(SUM(re_evaso_bw_fn)) AS diff_fn_forni_ricev, SUM(re_costo_bw_fn) AS costo_bw_fn,SUM(re_costo_ln_fn) AS costo_ln_fn FROM report_biblio as rb,biblio WHERE biblio.bi_id=rb.bi_idforni AND rb.bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rb.bi_idforni ORDER BY $ord"); + $tab = "

" . getConstVar("REPORTS_GRAPH_BIBLIO2H") . "


"; + $tab.=" + + + + + + + + + + + + + + + + + + + "; + $i = 0; + + if ($_SESSION['db']->numrows($result) == 0) { + $tab.=" "; + $tab.=" "; + $tab.=" "; + } else { + $CodACNPsmt = $_SESSION['db']->prepareSTMT("SELECT acnp_cod FROM tab_acnp WHERE bi_id=?"); + + while ($row = $_SESSION['db']->fetch($result)) { + $acnpcod = ""; + $CodACNPsmt->bind_param('i', $row['bi_idforni']); + $CodACNPsmt->execute(); + $CodACNPsmt->bind_result($acnpcod); + $CodACNPsmt->fetch(); + $CodACNPsmt->free_result(); + if ($acnpcod != "") + $acnpcod.=" - "; + + $i++; + $fornitrice = SQL_unescape($row["bi_nome"]); + $rich_bw = $row["ordini_inviati"]; + $num_ricev = $row["art_ricevuti"]; + $rich_ln = $row["ordini_ricevuti"]; + $num_forni = $row["art_forniti"]; + $diff_forni_ricev = $row["diff_forni_ricev"]; + $rich_fn_bw = $row["ordini_fn_inviati"]; + $num_fn_ricev = $row["art_fn_ricevuti"]; + $rich_fn_ln = $row["ordini_fn_ricevuti"]; + $num_fn_forni = $row["art_fn_forniti"]; + $diff_fn_ricev_forni = $row["diff_fn_forni_ricev"]; + $costo_fn_B = $row["costo_bw_fn"]; + $costo_fn_L = $row["costo_ln_fn"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + + if ($year >= date('Y') - getConstVar("HISTORY_DATE_INTERVAL")) { + $data = "&datarichie_from_aaaa=$year&datarichie_from_mm=1&datarichie_from_gg=1&datarichie_to_aaaa=$year&datarichie_to_mm=12&datarichie_to_gg=31"; + + if ($rich_bw > 0) { + $param1 = "tipo=1&label=0&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data; + $rich_bw = "$rich_bw"; + } + if ($num_ricev > 0) { + $param2 = "tipo=1&label=1&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data; + $num_ricev = "$num_ricev"; + } + if ($rich_ln > 0) { + $param3 = "tipo=1&label=0&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data; + $rich_ln = "$rich_ln"; + } + + if ($num_forni > 0) { + $param4 = "tipo=1&label=1&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data; + $num_forni = "$num_forni"; + } + + if ($rich_fn_bw > 0) { + $param1 = "tipo=1&label=3&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data; + $rich_fn_bw = "$rich_fn_bw"; + } + if ($num_fn_ricev > 0) { + $param2 = "tipo=1&label=4&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data; + $num_fn_ricev = "$num_fn_ricev"; + } + if ($rich_fn_ln > 0) { + $param3 = "tipo=1&label=3&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data; + $rich_fn_ln = "$rich_fn_ln"; + } + + if ($num_fn_forni > 0) { + $param4 = "tipo=1&label=4&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data; + $num_fn_forni = "$num_fn_forni"; + } + } + + $idbibpopup = $row['bi_idforni']; + $fornitrice = $acnpcod . "" . $fornitrice . "$baloon_library"; + $tab.=" + + + + + + + + + + + + + + + + + + "; + } + } + $tab.="
NILDE" . getConstVar("FN") . "
" . print_sorted_table_column('bi_nome', getConstVar("bi_nome"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('ordini_inviati', getConstVar("REPORTS_ORDINI_INVIATI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('art_ricevuti', getConstVar("REPORTS_ART_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('ordini_ricevuti', getConstVar("REPORTS_ORDINI_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('art_forniti', getConstVar("REPORTS_ART_FORNITI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('diff_forni_ricev', getConstVar("REPORTS_DIFF_ARTICOLI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('ordini_fn_inviati', getConstVar("REPORTS_ORDINI_INVIATI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('art_fn_ricevuti', getConstVar("REPORTS_ART_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('ordini_fn_ricevuti', getConstVar("REPORTS_ORDINI_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('art_fn_forniti', getConstVar("REPORTS_ART_FORNITI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('diff_fn_forni_ricev', getConstVar("REPORTS_DIFF_ARTICOLI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('costo_bw_fn', getConstVar("REPORTS_COSTO_BORROWING"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "" . print_sorted_table_column('costo_ln_fn', getConstVar("REPORTS_COSTO_LENDING"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "
" . getConstVar("NOWORKTODO") . "
" . $fornitrice . "" . $rich_bw . "" . $num_ricev . "" . $rich_ln . "" . $num_forni . "" . $diff_forni_ricev . "" . $rich_fn_bw . "" . $num_fn_ricev . "" . $rich_fn_ln . "" . $num_fn_forni . "" . $diff_fn_ricev_forni . "" . $costo_fn_B . " €" . $costo_fn_L . " €
"; + + return $tab; + break; + + case "biblio2I": + $result = $_SESSION['db']->execute("SELECT SUM(re_richieste_bw) as Richieste_Borrowing, SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel) as num_articoli_ricev, SUM(re_richieste_ln) as Richieste_Lending, SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro) as num_articoli_forniti, SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) as inevasi_bw,SUM(re_inevaso_ln_riferr)+SUM(re_inevaso_ln_nonposs)+SUM(re_inevaso_ln_nondisp)+SUM(re_inevaso_ln_over15)+SUM(re_inevaso_ln_overquota)+SUM(re_inevaso_ln_altro) as inevasi_ln,MONTH(STR_TO_DATE(re_mese,'%m')) as mese FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno = $year GROUP BY re_mese ORDER BY re_mese ASC "); + $data_richbw = array(); + $num_rich = array(); + $data_richln = array(); + $num_forni = array(); + $assex = array(); + $label = array(); + + $ret.= "

" . getConstVar("REPORTS_GRAPH_BIBLIO2I") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + while ($row = $_SESSION['db']->fetch($result)) { + $data_richbw[] = $row["inevasi_bw"]; + $num_rich[] = $row["num_articoli_ricev"]; + $data_richln[] = $row["inevasi_ln"]; + $num_forni[] = $row["num_articoli_forniti"]; + $assex[] = $row["mese"]; + } + foreach (getConstVar("ARRAY_MESI") as $k => $v) { + if (in_array($k, $assex)) { + $label[] = $v; + } + } + if ((array_sum($data_richbw) == 0) && (array_sum($num_rich) == 0) && (array_sum($data_richln) == 0) && (array_sum($num_forni) == 0)) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->SetScale('textint'); + $graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2")); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->legend->Pos(0.05, 0.01, 'top', 'left'); + $b1plot = new BarPlot($data_richbw); + $b1plot->SetFillColor('bisque3'); + $b1plot->SetLegend(getConstVar("REPORTS_BW_INEVASE")); + $b1plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 9); + $b1plot->value->Show(); + $b1plot->value->SetFormat('%01.0f'); + $b2plot = new BarPlot($num_rich); + $b2plot->SetFillColor("bisque"); + $b2plot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI")); + $b2plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 7); + $b2plot->value->Show(); + $b2plot->value->SetFormat('%01.0f'); + $b3plot = new BarPlot($data_richln); + $b3plot->SetFillColor("plum"); + $b3plot->SetLegend(getConstVar("REPORTS_LN_INEVASE")); + $b3plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 7); + $b3plot->value->Show(); + $b3plot->value->SetFormat('%01.0f'); + $b4plot = new BarPlot($num_forni); + $b4plot->SetFillColor("thistle"); + $b4plot->SetLegend(getConstVar("REPORTS_ART_FORNITI")); + $b4plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 7); + $b4plot->value->SetAngle(getConstVar("GRAPH_BAR_VALUE_ANGLE")); + $b4plot->value->Show(); + $b4plot->value->SetFormat('%01.0f'); + $gbplot = new GroupBarPlot(array($b1plot, $b2plot, $b3plot, $b4plot)); + $graph->Add($gbplot); + $graph->xaxis->SetTickLabels($label); + $graph->xaxis->SetFont(FF_DV_SERIF, FS_NORMAL, 8); + $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->xaxis->title->Set(getConstVar("MESI")); + $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9); + $graph->yaxis->title->Set(getConstVar("REPORTS_NUM_RICHIE")); + $ret.= print_tagimg($graph); + } + } + return $ret; + break; + + case "biblio2L": + $ord1 = "ricevuti"; + $ord2 = "forniti"; + $q1 = "desc"; + $q2 = "desc"; + if (isset($report_order)) { + if ($_REQUEST["gr"] == 1) { + $ord1 = $report_order; + $q1 = $report_qualif; + } else if ($_REQUEST["gr"] == 2) { + $ord2 = $report_order; + $q2 = $report_qualif; + } + } + $result = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_ricev) as ricevuti + FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (ricevuti>0) ORDER by $ord1 $q1 LIMIT 50"); + $result1 = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_forni) as forniti + FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (forniti > 0) ORDER by $ord2 $q2 LIMIT 50"); + $tit = ""; + $tabB = ""; + $tabL = ""; + $tit = "

" . getConstVar("REPORTS_GRAPHTITLE_BIBLIO2L") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0 && $_SESSION['db']->numrows($result1) == 0) { + $tabB = getConstVar("NOWORKTODO"); + $tabL = ""; + } else { + if ($_SESSION['db']->numrows($result) != 0) { + $tabB.=" + + + + + + "; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabB.=" + + + "; + $i++; + } + $tabB.="
" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2L"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2L&year=$year", "sort_report") . "" . print_sorted_table_column('ricevuti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_RICEVUTI"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2L&year=$year", "sort_report") . "
" . $row["rv"] . "" . $row["ricevuti"] . "
"; + } + + if ($_SESSION['db']->numrows($result1) != 0) { + $tabL.=" + + + + + + "; + $j = 0; + while ($row = $_SESSION['db']->fetch($result1)) { + $itemcl = "item1"; + if ($j % 2 != 0) + $itemcl = "item2"; + $tabL.=" + + + "; + $j++; + } + $tabL.="
" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2L"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2L&year=$year", "sort_report") . "" . print_sorted_table_column('forniti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_FORNITI"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2L&year=$year", "sort_report") . "
" . $row["rv"] . "" . $row["forniti"] . "
"; + } + } + if ($tabB != "") + $tabB.="
"; + return $tit . $tabB . $tabL; + break; + + case "biblio2M": + $ord1 = "ricevuti"; + $ord2 = "forniti"; + $q1 = "desc"; + $q2 = "desc"; + + if (isset($report_order)) { + if ($_REQUEST["gr"] == 1) { + $ord1 = $report_order; + $q1 = $report_qualif; + } else if ($_REQUEST["gr"] == 2) { + $ord2 = $report_order; + $q2 = $report_qualif; + } + } + $result = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_ricev) as ricevuti + FROM report_monografia WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (ricevuti>0) order by $ord1 $q1 LIMIT 50"); + $result1 = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_forni) as forniti + FROM report_monografia WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (forniti>0) order by $ord2 $q2 LIMIT 50"); + $tit = ""; + $tabB = ""; + $tabL = ""; + $tabbody = ""; + $tabbodyl = ""; + $tit = "

" . getConstVar("REPORTS_GRAPH_BIBLIO2M") . " ($year)


"; + + if ($_SESSION['db']->numrows($result) == 0 && $_SESSION['db']->numrows($result1) == 0) { + $tabB = getConstVar("NOWORKTODO"); + $tabL = ""; + } else { + if ($_SESSION['db']->numrows($result) != 0) { + $tabB.=" + + + + + + "; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabB.=" + + + "; + $i++; + } + $tabB.="
" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2M"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2M&year=$year", "sort_report") . "" . print_sorted_table_column('ricevuti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_RICEVUTI"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2M&year=$year", "sort_report") . "
" . $row["rv"] . "" . $row["ricevuti"] . "
"; + } + if ($_SESSION['db']->numrows($result1) != 0) { + $tabL.=" + + + + + + "; + $j = 0; + while ($row = $_SESSION['db']->fetch($result1)) { + $itemcl = "item1"; + if ($j % 2 != 0) + $itemcl = "item2"; + $tabL.=" + + + "; + $j++; + } + $tabL.="
" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2M"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2M&year=$year", "sort_report") . "" . print_sorted_table_column('forniti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_FORNITI"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2M&year=$year", "sort_report") . "
" . $row["rv"] . "" . $row["forniti"] . "
"; + } + } + if ($tabB != "") + $tabB.="
"; + return $tit . $tabB . $tabL; + break; + + case "utente3A": + $tab = ""; + $result = $_SESSION['db']->execute("SELECT SUM(re_evase_dir) as Evase_direttamente,SUM(re_inevase_dir) as Inevase_direttamente FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year"); + $ret.="

" . getConstVar("REPORTS_GRAPHTITLE_UTENTE3A") . " ($year)


"; + + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $i = 0; + $tabbody = ""; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["Evase_direttamente"]; + $data[] = $row["Inevase_direttamente"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["Evase_direttamente"] . " + " . $row["Inevase_direttamente"] . " + "; + $i++; + } + $legend = array(getConstVar("EVASE_DIR"), getConstVar("INEVASE_DIR")); + $datat[] = $legend; + $datat[] = $data; + if (array_sum($data) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($legend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("EVASE_DIR") . "" . getConstVar("INEVASE_DIR") . "
"; + } + } + + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "utente3B": + $nameview = "view_" . rand(0, 999999); //tabella + $result = $_SESSION['db']->execute("SELECT count(distinct ut_id) as num FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year AND re_richieste >= 1 "); + $_SESSION['db']->execute("CREATE VIEW $nameview AS SELECT SUM(re_richieste) as num_rich, ut_id FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_id"); + $result1 = $_SESSION['db']->execute("SELECT AVG(num_rich) as media, MAX(num_rich) as max FROM $nameview"); + $x = $_SESSION['db']->execute("DROP VIEW IF EXISTS $nameview"); + $result2 = $_SESSION['db']->execute("SELECT SUM(re_richieste) as num_rich FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year"); + + $ret.= "

" . getConstVar("REPORTS_GRAPH_UTENTE3B") . " ($year)


"; + $ret.= " "; + $ret.= " "; + + if ($_SESSION['db']->numrows($result) == 1) { + + $count = $_SESSION['db']->fetch($result); + $dati = $_SESSION['db']->fetch($result1); + $num = $_SESSION['db']->fetch($result2); + + + $ret.= " "; + $ret.= " "; + $ret.= " "; + $ret.= " "; + } + + $ret.= "
" . getConstVar("INDICATORE") . "" . getConstVar("VALORE") . "
" . getConstVar("REPORTS_GRAPH_UTENTE3B_RS") . "" . (($num["num_rich"] != null) ? $num["num_rich"] : '0') . "
" . getConstVar("REPORTS_GRAPH_UTENTE3B_RD") . "" . $count["num"] . "
" . getConstVar("REPORTS_GRAPH_UTENTE3B_MER") . "" . round($dati["media"], 2) . "
" . getConstVar("REPORTS_GRAPH_UTENTE3B_MAXR") . "" . ($dati["max"] != null ? $dati["max"] : '0') . "
"; + + return $ret; + break; + + case "utente3G": + $result = $_SESSION['db']->execute("SELECT SUM(re_richieste) as Numero_art_richiesti, ut_dip,dip_nome FROM report_utente LEFT JOIN dipartimento ON report_utente.ut_dip = dipartimento.dip_id WHERE report_utente.bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_dip; "); + $tab = ""; + $data = array(); + $data1 = array(); + $datalegend = array(); + $ret.="

" . getConstVar("REPORTS_GRAPH_UTENTE3G") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $tabbody = ''; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + if ($row["ut_dip"] == 0) + $row["dip_nome"] = strtoupper(getConstVar("SENZA_DIP")); + $datalegend[] = $row["dip_nome"]; + $data[] = $row["dip_nome"]; + $data1[] = $row["Numero_art_richiesti"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["dip_nome"] . " + " . $row["Numero_art_richiesti"] . " + "; + $i++; + } + $tabbody.=""; + if (array_sum($data1) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data1); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(5); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("REPORTS_DIPARTIMENTO") . "" . getConstVar("REPORTS_NUM_RICHIE") . "
"; + } + } + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "utente3H": + $result = $_SESSION['db']->execute("SELECT tq.qualifica as nome_qualifica, SUM( re_richieste ) as NUM_ART_RICHIESTI FROM report_utente AS ru, qualifica AS q,t_qualifica AS tq WHERE q.qu_id=tq.qu_id AND tq.lang_id='" . $_SESSION['lang'] . "' AND ru.qu_id = q.qu_id AND ru.bi_id=" . $_SESSION['biblio']->bi_id . " AND ru.re_anno=$year GROUP BY ru.qu_id "); + $ret.=""; + $tab = ""; + $data = array(); + $data1 = array(); + $datalegend = array(); + $ret.="

" . getConstVar("REPORTS_GRAPH_UTENTE3H") . " ($year)


"; + if ($_SESSION['db']->numrows($result) > 0) { + $tabbody = ''; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["nome_qualifica"]; + $data1[] = $row["NUM_ART_RICHIESTI"]; + $datalegend[] = $row['nome_qualifica']; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["nome_qualifica"] . " + " . $row["NUM_ART_RICHIESTI"] . " + "; + $i++; + } + $tabbody.=""; + + if (array_sum($data1) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + + $p1 = new PiePlot3D($data1); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("qu_id_LISTUTE_TITLE") . "" . getConstVar("REPORTS_NUM_RICHIE") . "
"; + } + } else + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "utente3I": + $result = $_SESSION['db']->execute("SELECT COUNT(distinct ut_id) as Numero_utenti, ut_dip,dip_nome FROM report_utente LEFT JOIN dipartimento ON report_utente.ut_dip = dipartimento.dip_id WHERE report_utente.bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_dip; "); + + $tab = ""; + $data = array(); + $data1 = array(); + $datalegend = array(); + $ret.="

" . getConstVar("REPORTS_GRAPH_UTENTE3I") . " ($year)


"; + if ($_SESSION['db']->numrows($result) > 0) { + $tabbody = ''; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + if ($row["ut_dip"] == 0) + $row["dip_nome"] = strtoupper(getConstVar("SENZA_DIP")); + $data[] = $row["dip_nome"]; + $data1[] = $row["Numero_utenti"]; + $datalegend[] = $row["dip_nome"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["dip_nome"] . " + " . $row["Numero_utenti"] . " + "; + $i++; + } + $tabbody.=""; + if (array_sum($data1) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data1); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(5); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("ut_dip_LISTUTE_TITLE") . "" . getConstVar("REPORTS_NUM_UTENTI") . "
"; + } + } else + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "utente3L": + $result = $_SESSION['db']->execute("SELECT COUNT(distinct ut_id) as Numero_utenti, tq.qualifica as Nome_qualifica FROM report_utente as ru, qualifica as q,t_qualifica AS tq WHERE q.qu_id=tq.qu_id AND tq.lang_id='" . $_SESSION['lang'] . "' AND ru.qu_id=q.qu_id AND ru.bi_id=" . $_SESSION['biblio']->bi_id . " AND ru.re_anno=$year GROUP BY ru.qu_id; "); + $tab = ""; + $data = array(); + $data1 = array(); + $datalegend = array(); + $ret.="

" . getConstVar("REPORTS_GRAPH_UTENTE3L") . " ($year)


"; + if ($_SESSION['db']->numrows($result) > 0) { + $tabbody = ''; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + $data[] = $row["Nome_qualifica"]; + $data1[] = $row["Numero_utenti"]; + $datalegend[] = $row["Nome_qualifica"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + $tabbody.=" + " . $row["Nome_qualifica"] . " + " . $row["Numero_utenti"] . " + "; + $i++; + } + $tabbody.=""; + if (array_sum($data1) == 0) { + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT")); + $graph->img->SetAntiAliasing(); + $graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM + $graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR")); + $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); + $p1 = new PiePlot3D($data1); + $p1->SetSize(getConstVar("PIE_SIZE")); + $p1->SetAngle(getConstVar("PIE_ANGLE")); + $p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y")); + $p1->ExplodeAll(getConstVar("PIE_EXPLODE")); + $p1->SetLegends($datalegend); + $graph->Add($p1); + $graph->legend->SetColumns(2); + $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); + $ret.= print_tagimg($graph); + $tab = " + + + + + + "; + $tab.=$tabbody; + $tab.="
" . getConstVar("qu_id_LISTUTE_TITLE") . "" . getConstVar("REPORTS_NUM_UTENTI") . "
"; + } + } else + $ret.= "
" . getConstVar("NOWORKTODO") . "
"; + $tab != null ? $tab : null; + $ret != null ? $ret : null; + return $ret . $tab; + break; + + case "utente3M": + $ord = ""; + $qual = ""; + $report_order = isset($report_order) ? $report_order : "ut_nome"; + $report_qualif = isset($report_qualif) ? $report_qualif : "asc"; + + if ($report_order == "ut_nome") { + $ord = "ut_cognome $report_qualif,$report_order $report_qualif"; + $qual = ""; + } else { + $ord = $report_order; + $qual = $report_qualif; + } + + $result = $_SESSION['db']->execute("SELECT u.ut_nome, u.ut_cognome, ru.ut_id, SUM(ru.re_richieste) AS richieste, SUM(ru.re_evase_dir) AS evase_dir, SUM(ru.re_evase_nilde) AS evase_nilde, (SUM(ru.re_inevase_nilde)+SUM(ru.re_inevase_dir)) AS inevase,re_costo_fn FROM report_utente as ru, utente as u WHERE ru.ut_id=u.ut_id AND ru.bi_id=" . $_SESSION['biblio']->bi_id . " AND ru.re_anno=$year GROUP BY ru.ut_id order by $ord $qual"); + $tab = "

" . getConstVar("REPORTS_GRAPH_UTENTE3M") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) { + $tab .= "
" . getConstVar("NOWORKTODO") . "
"; + } else { + $tab.=" + + + + + + + + + "; + + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + $i++; + $ut = $row["ut_cognome"] . " " . $row["ut_nome"]; + $richieste = $row["richieste"]; + $num_evase = $row["evase_dir"]; + $evase_nilde = $row["evase_nilde"]; + $num_inevase = $row["inevase"]; + $costo = $row["re_costo_fn"]; + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + + if ($year >= date('Y') - getConstVar("HISTORY_DATE_INTERVAL")) { + $data = "&datarichie_from_aaaa=$year&datarichie_from_mm=1&datarichie_from_gg=1&datarichie_to_aaaa=$year&datarichie_to_mm=12&datarichie_to_gg=31"; + + if ($richieste > 0) { + $param1 = "tipo=2&label=0&utesel=" . $row["ut_id"] . $data; + $richieste = "$richieste"; + } + if ($num_evase > 0) { + $param2 = "tipo=2&label=3&utesel=" . $row["ut_id"] . $data; + $num_evase = "$num_evase"; + } + + if ($num_inevase > 0) { + $param4 = "tipo=2&label=2&utesel=" . $row["ut_id"] . $data; + $num_inevase = "$num_inevase"; + } + } + + $tab.=" + + + + + + + + + "; + } + $tab.="
" . print_sorted_table_column('ut_nome', getConstVar("UTENTE"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "" . print_sorted_table_column('richieste', getConstVar("REPORTS_NUM_RICHIE"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "" . print_sorted_table_column('evase_dir', getConstVar("REPORTS_NUM_RICHIE_EVASE_DIR"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "" . print_sorted_table_column('inevase', getConstVar("REPORTS_NUM_RICHIE_INEVASE"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "" . print_sorted_table_column('re_costo_fn', getConstVar("REPORTS_COSTOFN"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "
" . $ut . "" . $richieste . "" . $num_evase . "" . $num_inevase . "" . $costo . " €
"; + return $tab; + } + break; + + case "utente3P": + $report_order = isset($report_order) ? $report_order : "dip_nome"; + $report_qualif = isset($report_qualif) ? $report_qualif : "asc"; + + $result = $_SESSION['db']->execute("SELECT ut_dip, SUM(re_costo_fn) AS costo_fn,dip_nome FROM report_utente LEFT join dipartimento ON ut_dip=dip_id WHERE report_utente.bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_dip HAVING costo_fn > 0 ORDER by $report_order $report_qualif"); + $tab = "

" . getConstVar("REPORTS_GRAPH_UTENTE3P") . " ($year)


"; + if ($_SESSION['db']->numrows($result) == 0) + $tab.= "
" . getConstVar("NOWORKTODO") . "
"; + else { + + $tab.=" + + + + + + "; + $i = 0; + while ($row = $_SESSION['db']->fetch($result)) { + $i++; + + $itemcl = "item1"; + if ($i % 2 != 0) + $itemcl = "item2"; + + if ($row["ut_dip"] == 0) + $row["dip_nome"] = strtoupper(getConstVar("SENZA_DIP")); + + $dip = $row["dip_nome"]; + $costo = $row["costo_fn"]; + + $tab.=" + + + + + + "; + } + + $tab.="
" . print_sorted_table_column('dip_nome', getConstVar("REPORTS_DIPARTIMENTO"), $report_order, $report_qualif, "reports.php?typegraph=utente3P&year=$year", "sort_report") . "" . print_sorted_table_column('costo_fn', getConstVar("REPORTS_COSTOFN"), $report_order, $report_qualif, "reports.php?typegraph=utente3P&year=$year", "sort_report") . "
" . $dip . "" . $costo . " €
"; + } + return $tab; + break; + + case "export_biblio": + $ret = ""; + $iconahelp = ""; + $ret .= "

" . getConstVar("EXPORT_BIBLIO") . " $iconahelp


"; + $ret.="" . getConstVar('EXPORT_BIBLIO_SCAMBI_GLOBALI') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_STATI_RICHIESTE') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_TEMPI_GIACENZA') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_RIVISTE_RICHIESTE') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_RIVISTE__RICHIESTE_DISTINTE') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_RIVISTE_FORNITE') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_UTENTI_ATTIVI') . "
"; + $ret.="" . getConstVar('EXPORT_BIBLIO_UTENTI_STATI') . ""; + + return $ret; + break; + + case "ente": + $iconahelp = ""; + $ret = ""; + $ret .= "

" . getConstVar("REPORTS_GRAPH_ENTE") . " $iconahelp


"; + $result = $_SESSION['db']->execute("SELECT ente.en_id,en_nome from storico_sottoscrizioni,ente where st_anno_contratto=$year and storico_sottoscrizioni.en_id=" . $_SESSION['biblio']->en_id . " AND ente.en_id=storico_sottoscrizioni.en_id"); + if ($result && $_SESSION['db']->numrows($result) == 1) { + $entearr = $_SESSION['db']->fetch_row($result); + $ret.="" . getConstVar("en_id") . ": " . $entearr['en_nome'] . "

"; + + $ret.="" . getConstVar('EXPORT_ENTE_BIBLIOTECHE') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_SCAMBI_GLOBALI') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_RICHIESTE_INTERNE') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_RICHIESTE') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_TEMPI_GIACENZA') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_RIVISTE_RICHIESTE') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_RIVISTE_RICHIESTE_DISTINTE') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_RIVISTE_FORNITE') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_UTENTI_ATTIVI') . "
"; + $ret.="" . getConstVar('EXPORT_ENTE_UTENTI_STATI') . ""; + } else + $ret.= "
" . getConstVar("REPORTS_NOREPORTENTE") . "
"; + + return $ret; + break; + + case "progetto": + $iconahelp = ""; + $ret = ""; + $ret .= "

" . getConstVar("REPORTS_GRAPH_PROJECT") . " $iconahelp


"; + $result = $_SESSION['db']->execute("SELECT DISTINCT pr_id, pr_nome from progetto where pr_id IN (SELECT pr_id from storico_sottoscrizioni where st_tipo_contratto=4 and st_anno_contratto=$year) and pr_id IN (select pr_id from biblio_progetto WHERE bi_id=" . $_SESSION['biblio']->bi_id . ")"); + $i = 0; + if ($_SESSION['db']->numrows($result) > 0) { + while ($pr_lst = $_SESSION['db']->fetch($result)) { + $pr = $pr_lst['pr_id']; + + $ret.="" . getConstVar("BIBLIO_PROGETTO") . ": " . $pr_lst["pr_nome"] . "

"; + $ret.="" . getConstVar('EXPORT_PROGETTO_BIBLIOTECHE') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_SCAMBI_GLOBALI') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_RICHIESTE_INTERNE') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_RICHIESTE') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_TEMPI_GIACENZA') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_RIVISTE_RICHIESTE') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_RIVISTE_RICHIESTE_DISTINTE') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_RIVISTE_FORNITE') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_UTENTI_ATTIVI') . "
"; + $ret.="" . getConstVar('EXPORT_PROGETTO_UTENTI_STATI') . "
"; + $ret.="

"; + $i++; + } + } else + $ret.= "
" . getConstVar("REPORTS_NOREPORTPROGETTO") . "
"; + + return $ret; + break; + } +} + +function export_graph_csv($typegraph, $year = null, $prog = null) { + srand(); + $rand = rand(); + $id = $_SESSION['biblio']->bi_id; + $filecsv = "$rand-$id-report_$typegraph.csv"; + $query = ""; + switch ($typegraph) { + case 'globale1A': $query = "SELECT SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel) as borrowing, SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel) AS lending, re_anno + FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno HAVING (borrowing > 0 OR lending > 0 )ORDER BY re_anno ASC"; + break; + + case "globale1E": $query = "SELECT re_anno,IFNULL(ROUND(SUM(re_tempo_risp_bw)/SUM(re_richieste_bw)/86400,2),0) as tempo_medio_B,IFNULL(ROUND(SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400,2),0) as tempo_medio_L FROM report_biblio where bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno"; + break; + + case "scambi_globali_ente": $query = "Select RIF.ri_id AS IDRIF,dd_id AS IDRICHIESTA,RIF.ri_titolopub AS TITOLO,RIF.ri_titolopart AS TITOLO_ARTICOLO_o_CAPITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,ri_anno AS ANNO,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN, + BR.bi_id AS ID_RICHIEDENTE,BR.bi_nome as RICHIEDENTE,(CASE BR.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,BF.bi_id AS ID_FORNITORE,BF.bi_nome as FORNITORE,(CASE BF.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_FORNITORE,BF.prov_id AS PROV_FORNITORE,ENTEF.en_nome AS ENTE_FORNITORE, + DD.dd_datarichie AS DATA_RICHIESTA,DD.dd_dataeva AS DATA_EVASIONE, + (CASE DD.dd_stato_ddill WHEN 0 THEN 'nuovo' WHEN 10 THEN 'inoltro NILDE' WHEN 11 THEN 'richiesto annullamento' WHEN 20 THEN 'inoltro FN' WHEN 99 THEN 'elaborazione server' WHEN 101 THEN 'evaso NILDE' WHEN 102 THEN 'evaso NILDE (HC)' WHEN 103 THEN 'evaso NILDE (WM)' WHEN 110 THEN 'evaso POSTA' WHEN 111 THEN 'evaso FAX'WHEN 112 THEN 'evaso ARIEL' WHEN 113 THEN 'evaso ALTRO' WHEN 150 THEN 'evaso FN' WHEN 201 THEN 'inevaso (riferim. errato)' WHEN 202 THEN 'inevaso (non posseduto)' WHEN 203 THEN 'inevaso (non disponibile)' WHEN 204 THEN 'inevaso (over 15)' WHEN 205 THEN 'inevaso (over quota)' WHEN 230 THEN 'inevaso ALTRO' WHEN 250 THEN 'inevaso FN' WHEN 299 THEN 'annullata' END ) AS STATO_DD, + (CASE DD.dd_stato_borr WHEN 0 THEN 'nuovo' WHEN 1 THEN 'in corso' WHEN 30 THEN 'attesa accettazione utente' WHEN 31 THEN 'utente rifiuta costo' WHEN 32 THEN 'utente accetta costo' WHEN 34 THEN 'utente non risponde' WHEN 40 THEN 'in gestione' WHEN 50 THEN 'scarìcato' WHEN 51 THEN 'ricevuto' WHEN 33 THEN 'cestinato' WHEN 70 THEN 'inevaso' WHEN 100 THEN 'consegnato ute/archiviato' WHEN 101 THEN 'consegnato (diretta)' WHEN 200 THEN 'non consegnato/arch come inevaso' WHEN 201 THEN 'non consegnato (diretto)' WHEN 202 THEN 'non consegnato (riferim. errato)' WHEN 203 THEN 'non consegnato (cestinato)' WHEN 300 THEN 'reiterato' WHEN 302 THEN 'reiterato (riferimento errato)' WHEN 303 THEN 'reiterato (cestinato)' END) AS STATO_BORROWING,if(ut_id IS NOT NULL AND ut_id>0,'Si','No') AS RICHIESTA_UTENTE + FROM docdel as DD,biblio as BR, biblio as BF, riferimento AS RIF,ente as ENTER,ente as ENTEF + WHERE DD.bi_idrichie=BR.bi_id AND DD.bi_idforni=BF.bi_id AND DD.ri_id=RIF.ri_id AND Year(dd_datarichie)=$year + AND ENTER.en_id=BR.en_id AND ENTEF.en_id=BF.en_id AND (BR.bi_id IN (SELECT bi_id from biblio WHERE en_id=" . $_SESSION['biblio']->en_id . " AND bi_nilde=1) + OR BF.bi_id IN (SELECT bi_id from biblio WHERE en_id=" . $_SESSION['biblio']->en_id . " AND bi_nilde=1) )"; + break; + + case "richieste_interne_ente": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN + FROM report_biblio, biblio AS BR,biblio as BF + WHERE report_biblio.bi_idrichie = BR.bi_id + AND report_biblio.bi_idforni = BF.bi_id + AND BR.en_id=" . $_SESSION['biblio']->en_id . " + AND BR.bi_nilde =1 + AND BF.en_id=" . $_SESSION['biblio']->en_id . " + AND BF.bi_nilde =1 + AND re_anno=$year + GROUP BY bi_idrichie"; + + break; + + case "richieste_ente": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN + FROM report_biblio, biblio AS BR + WHERE report_biblio.bi_idrichie = BR.bi_id + AND BR.en_id=" . $_SESSION['biblio']->en_id . " + AND BR.bi_nilde =1 + AND re_anno=$year + GROUP BY bi_idrichie"; + break; + + case "riviste_richieste_ente": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE + FROM docdel as DD,biblio as BR, riferimento AS RIF + WHERE + DD.bi_idrichie=BR.bi_id + AND DD.ri_id=RIF.ri_id + AND BR.en_id=" . $_SESSION['biblio']->en_id . " + AND BR.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "riviste_distinte_richieste_ente": $query = "select distinct (RIF.ri_titolopub) AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(*) as TOTALE + FROM docdel as DD,biblio as BR, riferimento AS RIF + WHERE + DD.bi_idrichie=BR.bi_id + AND DD.ri_id=RIF.ri_id + AND BR.en_id=" . $_SESSION['biblio']->en_id . " + AND BR.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "riviste_fornite_ente": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE + FROM docdel as DD,biblio as BF, riferimento AS RIF + WHERE + DD.bi_idforni=BF.bi_id + AND DD.ri_id=RIF.ri_id + AND BF.en_id=" . $_SESSION['biblio']->en_id . " + AND BF.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "utenti_attivi_ente": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV, COUNT(DISTINCT ut_id) as TOTALE + FROM report_utente,biblio + WHERE biblio.bi_id = report_utente.bi_id + AND re_anno=$year + AND re_richieste >= 1 + AND biblio.en_id =" . $_SESSION['biblio']->en_id . " + group by ID + order by TOTALE DESC"; + break; + + case "utenti_ente": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV, COUNT(ut_id) as TOTALE, SUM(IF(ap_stato = 0,1,0)) as ATTESA,SUM(IF(ap_stato = 1,1,0)) as ABILITATI,SUM(IF(ap_stato = 2,1,0)) as DISABILITATI + FROM biblio,appartiene + WHERE biblio.bi_id = appartiene.bi_id + AND ap_stato in (0,1,2) + AND biblio.en_id =" . $_SESSION['biblio']->en_id . " + group by ID + order by TOTALE DESC"; + break; + + case "tempi_giacenza_ente": $query = "Select BR.bi_id AS ID,BR.bi_nome as RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as TEMPO_MEDIO_GIACENZA + FROM report_biblio as rep,biblio as BR + WHERE bi_idrichie=BR.bi_id AND BR.en_id=" . $_SESSION['biblio']->en_id . " AND BR.bi_nilde=1 + AND re_anno=$year group by BR.bi_id"; + break; + + case "biblio_ente": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME,bi_indi AS INDIRIZZO,bi_cap AS CAP,bi_citta AS CITTA,prov_id AS PROV,bi_tel AS TELEFONO,bi_fax AS FAX,bi_url AS SITO,bi_opac AS URL_OPAC,bi_piva AS PIVA,bi_cf AS CF,bi_referente_dd AS REFERENTE,bi_email_dd AS EMAIL_REFERENTE,bi_tel_dd AS TEL_REFERENTE,bi_data_reg AS DATA_REGISTRAZIONE,acnp_cod AS COD_ACNP,(CASE acnp_attivo WHEN 0 THEN 'in attesa' WHEN 1 THEN 'attivo' WHEN 2 THEN 'disabilitato' END) as ACNP_LINK,sbn_cod AS COD_SBN,sbn_cod_polo AS COD_SBN_POLO from biblio LEFT JOIN tab_acnp ON biblio.bi_id=tab_acnp.bi_id LEFT JOIN tab_sbn ON biblio.bi_id=tab_sbn.bi_id WHERE bi_nilde=1 AND biblio.en_id=" . $_SESSION['biblio']->en_id; //bi_stato IN (".getConstVar('BIBLIO_ATTIVE_SQL_LIST').") + break; + + case "scambi_globali_progetto": $query = "Select RIF.ri_id AS IDRIF,dd_id AS IDRICHIESTA,RIF.ri_titolopub AS TITOLO,RIF.ri_titolopart AS TITOLO_ARTICOLO_o_CAPITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,ri_anno AS ANNO,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN, + BR.bi_id AS ID_RICHIEDENTE,BR.bi_nome as RICHIEDENTE,(CASE BR.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,BF.bi_id AS ID_FORNITORE,BF.bi_nome as FORNITORE,(CASE BF.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_FORNITORE,BF.prov_id AS PROV_FORNITORE,ENTEF.en_nome AS ENTE_FORNITORE, + DD.dd_datarichie AS DATA_RICHIESTA,DD.dd_dataeva AS DATA_EVASIONE, + (CASE DD.dd_stato_ddill WHEN 0 THEN 'nuovo' WHEN 10 THEN 'inoltro NILDE' WHEN 11 THEN 'richiesto annullamento' WHEN 20 THEN 'inoltro FN' WHEN 99 THEN 'elaborazione server' WHEN 101 THEN 'evaso NILDE' WHEN 102 THEN 'evaso NILDE (HC)' WHEN 103 THEN 'evaso NILDE (WM)' WHEN 110 THEN 'evaso POSTA' WHEN 111 THEN 'evaso FAX'WHEN 112 THEN 'evaso ARIEL' WHEN 113 THEN 'evaso ALTRO' WHEN 150 THEN 'evaso FN' WHEN 201 THEN 'inevaso (riferim. errato)' WHEN 202 THEN 'inevaso (non posseduto)' WHEN 203 THEN 'inevaso (non disponibile)' WHEN 204 THEN 'inevaso (over 15)' WHEN 205 THEN 'inevaso (over quota)' WHEN 230 THEN 'inevaso ALTRO' WHEN 250 THEN 'inevaso FN' WHEN 299 THEN 'annullata' END ) AS STATO_DD, + (CASE DD.dd_stato_borr WHEN 0 THEN 'nuovo' WHEN 1 THEN 'in corso' WHEN 30 THEN 'attesa accettazione utente' WHEN 31 THEN 'utente rifiuta costo' WHEN 32 THEN 'utente accetta costo' WHEN 34 THEN 'utente non risponde' WHEN 40 THEN 'in gestione' WHEN 50 THEN 'scarìcato' WHEN 51 THEN 'ricevuto' WHEN 33 THEN 'cestinato' WHEN 70 THEN 'inevaso' WHEN 100 THEN 'consegnato ute/archiviato' WHEN 101 THEN 'consegnato (diretta)' WHEN 200 THEN 'non consegnato/arch come inevaso' WHEN 201 THEN 'non consegnato (diretto)' WHEN 202 THEN 'non consegnato (riferim. errato)' WHEN 203 THEN 'non consegnato (cestinato)' WHEN 300 THEN 'reiterato' WHEN 302 THEN 'reiterato (riferimento errato)' WHEN 303 THEN 'reiterato (cestinato)' END) AS STATO_BORROWING,if(ut_id IS NOT NULL AND ut_id>0,'Si','No') AS RICHIESTA_UTENTE + FROM docdel as DD,biblio as BR, biblio as BF, riferimento AS RIF,ente as ENTER,ente as ENTEF + WHERE DD.bi_idrichie=BR.bi_id AND DD.bi_idforni=BF.bi_id AND DD.ri_id=RIF.ri_id AND Year(dd_datarichie)=$year + AND ENTER.en_id=BR.en_id AND ENTEF.en_id=BF.en_id AND + ( ( BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND BR.bi_nilde=1) OR ( BF.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND BF.bi_nilde=1) )"; + break; + + case "richieste_interne_progetto": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,ENTER.en_nome AS ENTE,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN + FROM report_biblio, biblio AS BR,biblio as BF,ente AS ENTER + WHERE report_biblio.bi_idrichie = BR.bi_id + AND report_biblio.bi_idforni = BF.bi_id + AND ENTER.en_id=BR.en_id + AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + AND BR.bi_nilde=1 + AND BF.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + AND BF.bi_nilde=1 + AND re_anno=$year + GROUP BY bi_idrichie"; + + break; + + case "richieste_progetto": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,ENTER.en_nome AS ENTE,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN + FROM report_biblio, biblio AS BR,ente as ENTER + WHERE report_biblio.bi_idrichie = BR.bi_id + AND ENTER.en_id=BR.en_id + AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + AND BR.bi_nilde =1 + AND re_anno=$year + GROUP BY bi_idrichie"; + break; + + case "riviste_richieste_progetto": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE + FROM docdel as DD,biblio as BR, riferimento AS RIF + WHERE + DD.bi_idrichie=BR.bi_id + AND DD.ri_id=RIF.ri_id + AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + AND BR.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "riviste_distinte_richieste_progetto": $query = "select distinct (RIF.ri_titolopub) AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(*) as TOTALE + FROM docdel as DD,biblio as BR, riferimento AS RIF + WHERE + DD.bi_idrichie=BR.bi_id + AND DD.ri_id=RIF.ri_id + AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + AND BR.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "riviste_fornite_progetto": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE + FROM docdel as DD,biblio as BF, riferimento AS RIF + WHERE + DD.bi_idforni=BF.bi_id + AND DD.ri_id=RIF.ri_id + AND BF.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + AND BF.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "utenti_attivi_progetto": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV,ente.en_nome AS ENTE, COUNT(DISTINCT ut_id) as TOTALE + FROM report_utente,biblio, ente + WHERE + ente.en_id=biblio.en_id + AND biblio.bi_id = report_utente.bi_id + AND re_anno=$year + AND re_richieste >= 1 + AND biblio.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + group by ID + order by TOTALE DESC"; + break; + + case "utenti_progetto": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV,ente.en_nome AS ENTE,COUNT(ut_id) as TOTALE, SUM(IF(ap_stato = 0,1,0)) as ATTESA,SUM(IF(ap_stato = 1,1,0)) as ABILITATI,SUM(IF(ap_stato = 2,1,0)) as DISABILITATI + FROM biblio,appartiene,ente + WHERE + ente.en_id=biblio.en_id + AND biblio.bi_id = appartiene.bi_id + AND ap_stato in (0,1,2) + AND biblio.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) + group by ID + order by TOTALE DESC"; + break; + + case "tempi_giacenza_progetto": $query = "Select BR.bi_id AS ID,BR.bi_nome as RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as TEMPO_MEDIO_GIACENZA + FROM report_biblio as rep,biblio as BR,ente AS ENTER + WHERE + ENTER.en_id=BR.en_id + AND bi_idrichie=BR.bi_id AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND BR.bi_nilde=1 + AND re_anno=$year group by BR.bi_id"; + break; + + case "biblio_progetto": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME,ente.en_nome AS ENTE,bi_indi AS INDIRIZZO,bi_cap AS CAP,bi_citta AS CITTA,prov_id AS PROV,bi_tel AS TELEFONO,bi_fax AS FAX,bi_url AS SITO,bi_opac AS URL_OPAC,bi_piva AS PIVA,bi_cf AS CF,bi_referente_dd AS REFERENTE,bi_email_dd AS EMAIL_REFERENTE,bi_tel_dd AS TEL_REFERENTE,bi_data_reg AS DATA_REGISTRAZIONE,acnp_cod AS COD_ACNP,(CASE acnp_attivo WHEN 0 THEN 'in attesa' WHEN 1 THEN 'attivo' WHEN 2 THEN 'disabilitato' END) as ACNP_LINK,sbn_cod AS COD_SBN,sbn_cod_polo AS COD_SBN_POLO from biblio LEFT JOIN tab_acnp ON biblio.bi_id=tab_acnp.bi_id LEFT JOIN tab_sbn ON biblio.bi_id=tab_sbn.bi_id LEFT JOIN ente ON ente.en_id=biblio.en_id WHERE bi_nilde=1 AND biblio.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND ente.en_id=biblio.en_id"; //bi_stato IN (".getConstVar('BIBLIO_ATTIVE_SQL_LIST').") + break; + + case "scambi_globali_biblio": $query = "Select RIF.ri_id AS IDRIF,dd_id AS IDRICHIESTA,RIF.ri_titolopub AS TITOLO,RIF.ri_titolopart AS TITOLO_ARTICOLO_o_CAPITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,ri_anno AS ANNO,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN, + BR.bi_id AS ID_RICHIEDENTE,BR.bi_nome as RICHIEDENTE,(CASE BR.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,BF.bi_id AS ID_FORNITORE,BF.bi_nome as FORNITORE,(CASE BF.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_FORNITORE,BF.prov_id AS PROV_FORNITORE,ENTEF.en_nome AS ENTE_FORNITORE, + DD.dd_datarichie AS DATA_RICHIESTA,DD.dd_dataeva AS DATA_EVASIONE, + (CASE DD.dd_stato_ddill WHEN 0 THEN 'nuovo' WHEN 10 THEN 'inoltro NILDE' WHEN 11 THEN 'richiesto annullamento' WHEN 20 THEN 'inoltro FN' WHEN 99 THEN 'elaborazione server' WHEN 101 THEN 'evaso NILDE' WHEN 102 THEN 'evaso NILDE (HC)' WHEN 103 THEN 'evaso NILDE (WM)' WHEN 110 THEN 'evaso POSTA' WHEN 111 THEN 'evaso FAX'WHEN 112 THEN 'evaso ARIEL' WHEN 113 THEN 'evaso ALTRO' WHEN 150 THEN 'evaso FN' WHEN 201 THEN 'inevaso (riferim. errato)' WHEN 202 THEN 'inevaso (non posseduto)' WHEN 203 THEN 'inevaso (non disponibile)' WHEN 204 THEN 'inevaso (over 15)' WHEN 205 THEN 'inevaso (over quota)' WHEN 230 THEN 'inevaso ALTRO' WHEN 250 THEN 'inevaso FN' WHEN 299 THEN 'annullata' END ) AS STATO_DD, + (CASE DD.dd_stato_borr WHEN 0 THEN 'nuovo' WHEN 1 THEN 'in corso' WHEN 30 THEN 'attesa accettazione utente' WHEN 31 THEN 'utente rifiuta costo' WHEN 32 THEN 'utente accetta costo' WHEN 34 THEN 'utente non risponde' WHEN 40 THEN 'in gestione' WHEN 50 THEN 'scarìcato' WHEN 51 THEN 'ricevuto' WHEN 33 THEN 'cestinato' WHEN 70 THEN 'inevaso' WHEN 100 THEN 'consegnato ute/archiviato' WHEN 101 THEN 'consegnato (diretta)' WHEN 200 THEN 'non consegnato/arch come inevaso' WHEN 201 THEN 'non consegnato (diretto)' WHEN 202 THEN 'non consegnato (riferim. errato)' WHEN 203 THEN 'non consegnato (cestinato)' WHEN 300 THEN 'reiterato' WHEN 302 THEN 'reiterato (riferimento errato)' WHEN 303 THEN 'reiterato (cestinato)' END) AS STATO_BORROWING,if(ut_id IS NOT NULL AND ut_id>0,'Si','No') AS RICHIESTA_UTENTE + FROM docdel as DD,biblio as BR, biblio as BF, riferimento AS RIF,ente as ENTER,ente as ENTEF + WHERE DD.bi_idrichie=BR.bi_id AND DD.bi_idforni=BF.bi_id AND DD.ri_id=RIF.ri_id AND Year(dd_datarichie)=$year + AND ENTER.en_id=BR.en_id AND ENTEF.en_id=BF.en_id AND ( (BR.bi_id=" . $_SESSION['biblio']->bi_id . " AND BR.bi_nilde=1) OR (BF.bi_id=" . $_SESSION['biblio']->bi_id . " AND BF.bi_nilde=1) )"; + break; + + case "richieste_biblio": $query = "SELECT sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN + FROM report_biblio + WHERE report_biblio.bi_idrichie=" . $_SESSION['biblio']->bi_id . " + AND re_anno=$year"; + break; + + case "riviste_richieste_biblio": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE + FROM docdel as DD,biblio as BR, riferimento AS RIF + WHERE + DD.bi_idrichie=BR.bi_id + AND DD.ri_id=RIF.ri_id + AND BR.bi_id=" . $_SESSION['biblio']->bi_id . " + AND BR.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "riviste_distinte_richieste_biblio": $query = "select distinct (RIF.ri_titolopub) AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(*) as TOTALE + FROM docdel as DD,biblio as BR, riferimento AS RIF + WHERE + DD.bi_idrichie=BR.bi_id + AND DD.ri_id=RIF.ri_id + AND BR.bi_id=" . $_SESSION['biblio']->bi_id . " + AND BR.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "riviste_fornite_biblio": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE + FROM docdel as DD,biblio as BF, riferimento AS RIF + WHERE + DD.bi_idforni=BF.bi_id + AND DD.ri_id=RIF.ri_id + AND BF.bi_id=" . $_SESSION['biblio']->bi_id . " + AND BF.bi_nilde=1 + AND Year(dd_datarichie)=$year + group by ri_titolopub + order by TOTALE desc"; + break; + + case "utenti_attivi_biblio": $query = "SELECT COUNT(DISTINCT ut_id) as TOTALE + FROM report_utente,biblio + WHERE biblio.bi_id = report_utente.bi_id + AND re_anno=$year + AND re_richieste >= 1 + AND biblio.bi_id=" . $_SESSION['biblio']->bi_id; + break; + + case "utenti_biblio": $query = "SELECT COUNT(ut_id) as TOTALE, SUM(IF(ap_stato = 0,1,0)) as ATTESA,SUM(IF(ap_stato = 1,1,0)) as ABILITATI,SUM(IF(ap_stato = 2,1,0)) as DISABILITATI + FROM biblio,appartiene + WHERE biblio.bi_id = appartiene.bi_id + AND ap_stato in (0,1,2) + AND biblio.bi_id=" . $_SESSION['biblio']->bi_id; + break; + + case "tempi_giacenza_biblio": $query = "Select SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as TEMPO_MEDIO_GIACENZA + FROM report_biblio as rep,biblio as BR + WHERE bi_idrichie=BR.bi_id AND BR.bi_id=" . $_SESSION['biblio']->bi_id . " AND BR.bi_nilde=1 + AND re_anno=$year"; + break; + } + if ($query != "") { + $csv_content = $_SESSION['db']->exportQuery2CSV($query); + $path = getConstVar('CSV_TMP_DIR') . $filecsv; + $fp = fopen($path, "w"); + fwrite($fp, $csv_content); + fclose($fp); + $size = formatBytes(filesize($path)); + echo "  " . getConstVar('FILE_READY') . " ($size)"; + } +} + +function export_graph_pdf($graph, $year = null) { + return null; +} + +$report_order = null; + +if (isset($_REQUEST["order"])) + $report_order = $_REQUEST["order"]; + +if (isset($_REQUEST["qualif"])) + $report_qualif = $_REQUEST["qualif"]; + +if (isset($_GET['export'])) { + switch ($_GET['export']) { + case "csv": export_graph_csv($_GET["typegraph"], $_GET["year"], $_GET["prog"]); + break; + case "pdf": export_graph_pdf($_GET["typegraph"], $_GET["year"]); + break; + } +} else +if (isset($_GET["typegraph"])) + echo print_graph($_GET["typegraph"], $_GET["year"], $report_order, $report_qualif); +?> \ No newline at end of file diff --git a/scripts/ajax_engine_biblio.php b/scripts/ajax_engine_biblio.php new file mode 100755 index 0000000..3ebd225 --- /dev/null +++ b/scripts/ajax_engine_biblio.php @@ -0,0 +1,2709 @@ +var firstClick=1; +var from3to4Save= new Array(0,0,0); + +function auto_aggiorna_liste() +{ + if($('view_borrowing_box') && $('view_borrowing_box').hasClassName('selected_lib_area') && $('current_list').visible() && !$('my_request').visible()) + { + update_list('action_listaborrowing.php?op=aggiorna') + } + else + if($('view_lending_box') && $('view_lending_box').hasClassName('selected_lib_area') && $('current_list').visible() && !$('my_request').visible()) + { + update_list('action_listalending.php?op=aggiorna') + } +} + +new PeriodicalExecuter(auto_aggiorna_liste, 300); + + +function next_step(step) { + + var param=$('form_reg_lib').serialize()+"&op=next_step&step="+step; + + req=new Ajax.Request("action_biblio.php", + { + method:'POST', + parameters: param, + onComplete: function (transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + case "502": + case "503": + clear_incomplete_fields("form_reg_lib") + show_incomplete_fields(values["fields"]); + $('registration_feedback').update(msg); + goTop(); + break; + case "201": + clear_incomplete_fields("form_reg_lib") + $('public_area').update(res); + goTop(); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); +} + + +function prev_step(step) { + new Ajax.Request("action_biblio.php", + { + method:'POST', + parameters: { op: 'prev_step', step: step}, + onComplete: function (transport) { + $('public_area').update(transport.responseText); + goTop(); + } + }); +} + +function enable_cat(nome) { + + if ($('ca_nome_'+nome).className == 'ca_nome_disabled') { + $('ca_nome_'+nome).removeClassName('ca_nome_disabled'); + $('ca_nome_'+nome).toggleClassName('ca_nome'); + var campi = $('ca_nome_'+nome).getElementsByTagName('input') + for (var i = 0; i < campi.length; i++) + campi[i].removeAttribute('disabled'); + + } + else { + $('ca_nome_'+nome).removeClassName('ca_nome'); + $('ca_nome_'+nome).toggleClassName('ca_nome_disabled'); + + var campi = $('ca_nome_'+nome).getElementsByTagName('input') + for (var i = 0; i < campi.length; i++) + { + campi[i].setAttribute('disabled', 'disabled'); + campi[i].value=""; + } + + } + +} + +function reset_link_label(labelid) +{ + if($(labelid)) + $(labelid).update(''); +} + +function updateInst() +{ + if($('ti_id').selectedIndex!=0) + { + new Ajax.Request("action_biblio.php?op=filter_inst", + { + method:'POST', + parameters: {ti_id: $('ti_id').options[$('ti_id').selectedIndex].value,na_id: $('na_id').options[$('na_id').selectedIndex].value}, + onComplete: function(transport) + { + if(transport.responseText!="") + { + Element.replace('en_id_box_sel',transport.responseText); + $('en_id_box_sel').show(); + } + } + }); + } + else { + $('en_id_box_sel').update(); + } + +} + +function updateByNation() +{ + if($('na_id').selectedIndex!=0) + { + $('prov_id_box_sel').update(""); + $('en_id_box_sel').update(""); + $('en_id_box_sel').hide(); + $('ti_id_box_sel').update(""); + $('ti_id_box_sel').hide(); + new Ajax.Request("action_biblio.php?op=filter_prov_by_nation", + { + method:'POST', + parameters: $('form_reg_lib').serialize(true), + onComplete: function(transport) + { + if(transport.responseText!="") + { + Element.replace('prov_id_box_sel',transport.responseText); + } + } + }); + + new Ajax.Request("action_biblio.php?op=filter_insttype_by_nation", + { + method:'POST', + parameters: $('form_reg_lib').serialize(true), + onComplete: function(transport) + { + if(transport.responseText!="") + { + $('ti_id_box_sel').update(transport.responseText); + $('ti_id_box_sel').show(); + } + } + }); + } + else { + $('prov_id_box_sel').update(""); + $('en_id_box_sel').update(""); + $('en_id_box_sel').hide(); + $('ti_id_box_sel').update(""); + $('ti_id_box_sel').hide(); + } + +} + +function deselectPanel(pname) +{ + if($(pname).hasClassName('selected_lib_area')) + $(pname).removeClassName('selected_lib_area'); +} + +function selectPanel(pname) +{ + $(pname).toggleClassName('selected_lib_area'); +} + +function loadPanel(pan) +{ + + new Ajax.Request("action_library.php", + { + method:'GET', + asynchronous: false, + parameters: { op: 'loadpanel',panel: pan }, + onComplete: function (transport) + { + $('lib_panel').update(transport.responseText); + } + }); +} + +function showBorrowing() +{ + if(!$('view_borrowing_box').hasClassName('selected_lib_area')) + { + deselectPanel('view_lending_box'); + deselectPanel('view_users_box'); + deselectPanel('view_reports_box'); + deselectPanel('view_history_box'); + + loadPanel('borrowing') + + selectPanel('view_borrowing_box'); + } + +} + +function showBW() +{ + if(!$('view_borrowing_box').hasClassName('selected_lib_area')) + { + deselectPanel('view_lending_box'); + deselectPanel('view_users_box'); + deselectPanel('view_reports_box'); + deselectPanel('view_history_box'); + selectPanel('view_borrowing_box'); + } + +} + + + + +function showLending() +{ + if(!$('view_lending_box').hasClassName('selected_lib_area')) + { + deselectPanel('view_borrowing_box'); + deselectPanel('view_users_box'); + deselectPanel('view_reports_box'); + deselectPanel('view_history_box'); + + loadPanel('lending') + selectPanel('view_lending_box'); + } +} + +function showUsers() +{ + if(!$('view_users_box').hasClassName('selected_lib_area')) + { + deselectPanel('view_borrowing_box'); + deselectPanel('view_lending_box'); + deselectPanel('view_reports_box'); + deselectPanel('view_history_box'); + + loadPanel('users') + selectPanel('view_users_box'); + } + +} + +//DIADOSIS TEAM +function showUsersForDepartment(k) +{ + + deselectPanel('view_borrowing_box'); + deselectPanel('view_lending_box'); + deselectPanel('view_reports_box'); + deselectPanel('view_history_box'); + arg = 'users_'+k; + loadPanel(arg) + selectPanel('view_users_box'); + toggle_department_creator(); + + +} + +function showReports() +{ + if(!$('view_reports_box').hasClassName('selected_lib_area')) + { + deselectPanel('view_borrowing_box'); + deselectPanel('view_lending_box'); + deselectPanel('view_users_box'); + deselectPanel('view_history_box'); + loadPanel('reports') + selectPanel('view_reports_box'); + } +} + +function showHistory() +{ + if(!$('view_history_box').hasClassName('selected_lib_area')) + { + deselectPanel('view_borrowing_box'); + deselectPanel('view_lending_box'); + deselectPanel('view_users_box'); + deselectPanel('view_reports_box'); + + loadPanel('history') + selectPanel('view_history_box'); + } +} + +function showBiblioAccount() +{ + toggleBox('account_infos','expand_account','expand_v_up','expand_v_down',0) +} + +function modificaBiblioAccount() +{ + req=new Ajax.Request("action_biblio.php", + { + method:'POST', + parameters: $('form_library').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + + switch (statusResp) + { + case "201": + $('library_dynamic').update(res); + from3to4Save[0] = 1; + positive_account_feedback(msg) + break; + + case "501": + case "502": + clear_incomplete_fields("form_utente") + show_incomplete_fields(values["fields"]); + negative_account_feedback(msg) + break; + + case "503": + $('library_dynamic').update(res); + negative_account_feedback(msg) + break; + } + } + else + { + $('library_dynamic').update(transport.responseText); + } + } + }); + } + +function salvaBiblioAccount() +{ + document.form_library.submit() +} + +function undoModificaBiblio() +{ + if(confirm('')) + { + new Ajax.Request("action_biblio.php?op=undoedit", + { + method:'GET', + onComplete: function (transport) + { + $('library_dynamic').update(transport.responseText); + } + }); + } +} + + +function resetta_account() +{ + if(confirm('')) + { + new Ajax.Request("action_biblio.php?op=undoedit", + { + method:'GET', + onComplete: function (transport) + { + $('library_dynamic').update(transport.responseText); + $('expand_account').href="javascript:showBiblioAccount()"; + showBiblioAccount() + } + }); + } + +} + + +function account_feedback_visible() +{ + goTop(); + return show_feedback('account_feedback'); +} + +function hide_account_feedback() +{ + hide_feedback('account_feedback'); +} + +function update_account_feedback(msg) +{ + update_feedback('account_feedback',msg); + goTop(); +} + +function positive_account_feedback(msg) +{ + positive_feedback('account_feedback',msg); + goTop(); +} + + +function negative_account_feedback(msg) +{ + negative_feedback('account_feedback',msg); + goTop(); +} + +function modificaService() +{ + req=new Ajax.Request("action_biblio.php", + { + method:'POST', + parameters: $('form_library_serv').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + + switch (statusResp) + { + case "201": + $('library_service_dynamic').update(res); + from3to4Save[1] = 1; + positive_account_feedback(msg) + break; + + case "501": + clear_incomplete_fields("form_library_serv") + show_incomplete_fields(values["fields"]); + negative_account_feedback(msg) + break; + + case "503": + $('library_service_dynamic').update(res); + negative_account_feedback(msg) + break; + } + } + else + { + $('library_service_dynamic').update(transport.responseText); + } + } + }); +} + +function undoModificaService() +{ + if(confirm('')) + { + new Ajax.Request("action_biblio.php?op=undoeditServ", + { + method:'GET', + onComplete: function (transport) + { + $('library_service_dynamic').update(transport.responseText); + } + }); + } +} + + +function salvaService() +{ + document.form_library_serv.submit() +} + +function modificaCataloghi() +{ + req=new Ajax.Request("action_biblio.php", + { + method:'POST', + parameters: $('cat_data_form').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + + switch (statusResp) + { + case "201": + $('library_cat_dynamic').update(res); + from3to4Save[2] = 1; + positive_account_feedback(msg) + break; + + case "501": + clear_incomplete_fields("cat_data_form") + show_incomplete_fields(values["fields"]); + negative_account_feedback(msg) + break; + + case "503": + $('library_cat_dynamic').update(res); + negative_account_feedback(msg) + break; + } + } + else + { + $('library_cat_dynamic').update(transport.responseText); + } + } + }); + } + +function undoModificaCataloghi() +{ + if(confirm('')) + { + new Ajax.Request("action_biblio.php?op=undoeditCat", + { + method:'GET', + onComplete: function (transport) + { + $('library_cat_dynamic').update(transport.responseText); + } + }); + } +} + +function salvaCataloghi() +{ + document.cat_data_form.submit() +} + +function update_list(url) +{ + if($('search_lib_feedback_box')) + $('search_lib_feedback_box').update(""); + + new Ajax.Request(url, + { + method:'GET', + onComplete: function(transport) + { + Element.replace('current_list',transport.responseText); + } + }); +} + +function update_list_by_label(url) +{ + el=$('label') + label=el.options[el.selectedIndex].value; + url=url+"&label="+eval(label) + update_list(url); +} + +function update_list_by_range(url) +{ + el=$('passo') + pass=el.options[el.selectedIndex].value; + + url=url+"&passo="+eval(pass) + update_list(url); +} + +function display_user_details(userid) +{ + + alert("display_user_details - Not Implemented"); +} + +function display_biblio_details(biblioid,element) +{ + alert("display_biblio_details - Not Implemented"); +} + +function annulla_richiesta(id) +{ + var conf=true; + conf=confirm(''); + + + if(conf) + req=new Ajax.Request('action_borrowing.php', + { + method:'GET', + parameters: {op:'ric_annulla',dd_id: id }, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + default: alert("Error Ajax contact support"); break; + } + } + else + update_list("action_listaborrowing.php?op=aggiorna"); + } + }); + +} + +function closeRequestPanel_noconfirm(url) +{ + + if($('view_borrowing_box').hasClassName('selected_lib_area')) clean_borrowing_session(); + + else if($('view_lending_box').hasClassName('selected_lib_area')) clean_lending_session(); + + + blankRequest(); + + $('request_box').setStyle({ + position: 'absolute', + width: '46.5%', + left: '-45%', + marginRight: '-8%', + marginLeft: '37px' + }); + + $('lib_nav').setStyle({ + visibility: 'visible' + }); + + $('pillow2').setStyle({ + width: '97%' + }); + + if($('request_list_tools') && !$('request_list_tools').visible()) + $('request_list_tools').show(); + + if($('current_list') && !$('current_list').visible()) + $('current_list').show(); + + $('form_libserv').setStyle({ + height: 'auto' + }); + + if(url!=null) + update_list(url+'?op=aggiorna'); + + if($('reports')) $('reports').show(); + + +} + +function closeRequestPanel(url) +{ + + var conf=true; + conf=confirm(''); + + if(conf){ + closeRequestPanel_noconfirm(url); + firstClick=1; + } +} + +function closeAndSaveRequestPanel(url_req,url_lista) +{ + param=$('form_richiesta').serialize()+"&op=save_req"; + req=new Ajax.Request(url_req, + { + method:'POST', + parameters: param, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list(url_lista+'?op=aggiorna'); + negative_serv_feedback(msg); + break; + + case "501": + clear_incomplete_fields("form_richiesta") + clear_incomplete_fields("form_richiesta_manger") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + closeRequestPanel_noconfirm(); + update_list(url_lista+'?op=aggiorna'); + break; + } + } + + } + + }); +} + +function caricaListaBiblioteche(elenco_sel) +{ + new Ajax.Request("action_borrowing.php", + { + method:'POST', + asynchronous: false, + parameters: { op: 'cambia_lista',tipo: elenco_sel }, + onComplete: function (transport) { + Element.replace('search_lib_list',transport.responseText); + $('search_lib_feedback_box').update(""); + } + }); + + if(elenco_sel=="300") + op='bottoni_biblio_fuorinilde' + else + op='bottoni_biblio_nilde' + + + new Ajax.Request("action_borrowing.php", + { + method:'POST', + asynchronous: false, + parameters: { op: op}, + onComplete: function (transport) + { + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + asynchronous: false, + parameters: { op: 'aggiorna' }, + onCreate: function(){ + $('search_lib_list_loading').update(" Loading..."); + $('search_lib_list_loading').show(); + }, + onComplete: function(transport) { + $('lib_list').update(transport.responseText); + $('search_lib_list_loading').remove(); + } + }); + $('form_richiesta_manager').update(transport.responseText); + } + }); + +} + +function showListaBiblio(elenco_sel) +{ + if(!$('view_'+elenco_sel+'_box').hasClassName('selected_search_lib_area')) { + lista=$('search_lib_nav').select('[class="selected_search_lib_area"]') + + lista.each(function(el) { + el.removeClassName("selected_search_lib_area"); + }); + + caricaListaBiblioteche(elenco_sel) + + $('view_'+elenco_sel+'_box').toggleClassName('selected_search_lib_area'); + } +} + +function newRequest(url,type) +{ + + req1=new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'check_req_session' }, + onComplete: function (transport) + { + if(isAjaxXMLRequest(req1)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + case "201": + + firstClick=1; + if(!type) + { + new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'choose_type' }, + onComplete: function (transport) + { + Element.replace('my_request',transport.responseText); + openFullRequestPanel() + } + }); + } + else + { + $('discard_o').remove(); + req=new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'new_req',req_type: type }, + onComplete: function (transport) + { + $('my_request').hide(); + Element.replace('my_request',transport.responseText); + $('my_request').show(); + } + }); + } + + break; + + default: alert("ERROR MULTIPLE REQUESTS: contact your administrator"); break; + } + } + + } + }); +} + +function newRequestFromOpenURL(url,tipo,bibrich,bibforni) +{ + req1=new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'check_req_session' }, + onComplete: function (transport) + { + if(isAjaxXMLRequest(req1)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + case "201": + + + req=new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'new_req_openurl',req_type: tipo,idrich:bibrich,idforni:bibforni }, + onComplete: function (transport) + { + $('my_request').hide(); + Element.replace('my_request',transport.responseText); + openFullRequestPanel(); + } + }); + break; + } + } + } + }); +} + + + +function openRequest(url,id) +{ + + req=new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'open_req',dd_id: id }, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + default: alert("ERROR MULTIPLE REQUESTS: contact your administrator"); break; + } + } + else + { + Element.replace('my_request',transport.responseText); + openFullRequestPanel(); + } + + } + + }); +} + +function openFullRequestPanel() +{ + if($('request_list_tools')) $('request_list_tools').hide(); + if ($('current_list')) $('current_list').hide(); + + $('lib_nav').setStyle({ + visibility: 'hidden' + }); + + $('pillow2').setStyle({ + width: '0%', + + }); + + + $('request_box').setStyle({ + position: 'relative', + left: '1.5%', + width: '94.5%', + marginRight: '-9%', + marginLeft: '0' + }); + + $('my_request').show() +} + +function openRequestPanel() +{ + goServTop(); + $('expand_o').show(); + $('request_box').setStyle({ + position: 'relative', + left: '1.5%', + width: '46.5%', + marginRight: '-8%', + marginLeft: '0' + }); + + $('pillow2').setStyle({ + width: '53.5%' + }); + + + $('request_list_tools').show(); + $('current_list').show(); + + $('expand_o').show(); + + if($('discard_o').visible()) + $('discard_o').hide(); + + $('form_libserv').setStyle({ + height: 'auto' + }); + $('my_request').show() +} + +function blankRequest() +{ + Element.replace('request',"
"); +} + +function passo2Borrowing() +{ + var param=$('form_richiesta').serialize()+"&op=avanti"; + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + + case "501": + clear_incomplete_fields("form_richiesta") + clear_incomplete_fields("form_richiesta_manager"); + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "504": + clear_incomplete_fields("form_richiesta") + clear_incomplete_fields("form_richiesta_manager"); + negative_serv_feedback(msg) + break; + case "201": + clear_incomplete_fields("form_richiesta"); + clear_incomplete_fields("form_richiesta_manager"); + Element.replace('form_richiesta', res); + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: { op: 'aggiorna' }, + onCreate: function(){ + $('search_lib_list_loading').update(" Loading..."); + $('search_lib_list_loading').show(); + }, + onComplete: function(transport) { + $('lib_list').update(transport.responseText); + $('search_lib_list_loading').remove(); + } + }); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); +} + +function passo1Borrowing() +{ +firstClick=1; + req=new Ajax.Request('action_borrowing.php', + { + method:'GET', + parameters: {op:'indietro'}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + + default: alert("Errore AJAX: contattare il supporto tecnico"); break; + } + } + else + Element.replace('form_richiesta',transport.responseText); + } + }); +} + +function operazioneBorrowing(op) { + var conf=true; + + conf=confirm(''); + + var param=$('form_richiesta').serialize()+"&op="+op; + + if(conf){ + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + case "501": + clear_incomplete_fields("form_richiesta") + clear_incomplete_fields("form_richiesta_manager"); + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + closeRequestPanel_noconfirm(); + positive_serv_feedback(msg); + + update_list("action_listaborrowing.php?op=aggiorna"); + break; + default: + alert ("Error Ajax contact support:"+transport.responseText); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); + } +} + +function evasione_FN(op,eva) { + + var param=$('form_richiesta').serialize()+"&op="+op+"&eva="+eva; + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + case "501": + clear_incomplete_fields("form_richiesta") + clear_incomplete_fields("form_richiesta_manager"); + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + clear_incomplete_fields("form_richiesta") + clear_incomplete_fields("form_richiesta_manager") + Element.replace('form_richiesta',res); + break; + + default: + alert("Error Ajax contact support:"+transport.responseText); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); +} + +function cancella_file() +{ + var conf=true; + conf=confirm(''); + + var param=$('form_richiesta').serialize()+"&op=cancella_file"; + + if(conf) { + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + + case "501": + clear_incomplete_fields("form_richiesta") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + clear_incomplete_fields("form_richiesta") + Element.replace('form_richiesta_manager',res); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); + + } +} + +function cestina() +{ + var conf=true; + conf=confirm(''); + + var param=$('form_richiesta').serialize()+"&op=cestina"; + + if(conf) { + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + + case "501": + clear_incomplete_fields("form_richiesta") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + clear_incomplete_fields("form_richiesta") + $('form_richiesta_manager').remove(); + $('discard_save_box').remove(); + $('discard_save_small_box').remove(); + Element.replace('form_richiesta',res); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); + } +} + +function cestina_automatica() +{ + var param=$('form_richiesta').serialize()+"&op=cestina"; + + req=new Ajax.Request('action_borrowing.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) { + if(isAjaxXMLRequest(req)) { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list("action_listaborrowing.php?op=aggiorna"); + negative_serv_feedback(msg); + break; + + case "501": + clear_incomplete_fields("form_richiesta") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + clear_incomplete_fields("form_richiesta") + $('form_richiesta_manager').remove(); + $('discard_save_box').remove(); + $('discard_save_small_box').remove(); + Element.replace('form_richiesta',res); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText) + } + }); +} + +function save_collocazione(bibid) +{ + if ($('collocaz10n3_'+bibid)) + $('dd_collocazione').value = $('collocaz10n3_'+bibid).innerHTML; + else $('dd_collocazione').value=""; +} + +function evasioneLending(url) +{ + req=new Ajax.Request(url, + { + method:'GET', + parameters: {op:'pannello_evadi'}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "555": + closeRequestPanel_noconfirm(); + update_list('action_listalending.php?op=aggiorna'); + negative_serv_feedback(msg); + break; + default: alert("Error Ajax contact support"); break; + } + } + else + Element.replace('form_richiesta_manager',transport.responseText); + } + + }); +} + +function inevasioneLending(url) +{ + req=new Ajax.Request(url, + { + method:'GET', + parameters: {op:'pannello_inevadi'}, + onComplete: function(transport) + { + + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "555": + closeRequestPanel_noconfirm(); + update_list('action_listalending.php?op=aggiorna'); + negative_serv_feedback(msg); + break; + default: alert("Error Ajax contact support"); break; + } + } + else + Element.replace('form_richiesta_manager',transport.responseText); + } + + }); +} + +function evadiLending(url) +{ + param=$('form_richiesta').serialize()+"&op=evadi"; + req=new Ajax.Request(url, + { + method:'POST', + parameters: param, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list('action_listalending.php?op=aggiorna'); + negative_serv_feedback(msg); + break; + + case "501": + if($('form_richiesta')) + clear_incomplete_fields("form_richiesta") + + clear_incomplete_fields("form_richiesta_fields") + clear_incomplete_fields("form_richiesta_manager") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + + case "502": + negative_serv_feedback(msg) + break; + + case "201": + closeRequestPanel_noconfirm(); + positive_serv_feedback(msg); + update_list('action_listalending.php?op=aggiorna'); + break; + + default: + alert ("Error Ajax contact support:"+transport.responseText); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText); + + } + }); + +} + +function inevadiLending(url) +{ + + param=$('form_richiesta').serialize()+"&op=inevadi"; + req = new Ajax.Request(url, + { + method:'POST', + parameters: param, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)){ + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "555": + closeRequestPanel_noconfirm(); + update_list('action_listalending.php?op=aggiorna'); + negative_serv_feedback(msg); + break; + case "501": + clear_incomplete_fields("form_richiesta_fields") + clear_incomplete_fields("form_richiesta_manager") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "201": + closeRequestPanel_noconfirm(); + positive_serv_feedback(msg); + update_list('action_listalending.php?op=aggiorna'); + break; + default: + alert ("Error Ajax contact support:"+transport.responseText); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText); + } + }); +} + + + +function accetta_annulla(id) { + var conf=true; + conf=confirm(''); + + if(conf) + new Ajax.Request('action_lending.php', + { + method:'GET', + parameters: {op:'accetta_annulla',dd_id: id }, + onComplete: function(transport) { + closeRequestPanel_noconfirm(); + positive_serv_feedback(''); + update_list("action_listalending.php?op=aggiorna"); + } + }); +} + +function changeEvaType() +{ + if($('dd_stato_ddill').selectedIndex==0) + { + $('upload_box').show(); + start_upload_lending(); + } + else + { + $('upload_box').hide(); + $('big_btn_plain_g').show(); + + if($('dd_file') && $('dd_file').visible()) + { + $('dd_file').hide(); + $('dd_file').value=""; + $('check_hc').hide(); + } + $('form_richiesta').writeAttribute('enctype',null); + $('form_richiesta').writeAttribute('target',null); + } +} + +function print_references() +{ + alert("Print References - not implemented"); +} + + +function visualizza_utente(id) +{ + new Ajax.Request('action_listautenti.php', + { + method:'GET', + parameters: {op:'visualizza_utente',ut_id: id }, + onComplete: function(transport) { + $('person_dynamic').update(transport.responseText) + } + }); +} + +function check_all_users() +{ + var form = $('form_libusers') + + var ut_check = form.getInputs('checkbox', 'idut[]') + + for (var i = 0; i < ut_check.length; i++) + { + ut_check[i].checked=$('checkall').checked; + } +} + +function cambia_stato_utente(id,stato) +{ + var conf=true; + if (stato == "abilita") + conf=confirm(''); + else + conf=confirm(''); + if(conf) + new Ajax.Request('action_listautenti.php', + { + method:'GET', + asynchronous:false, + parameters: {op:stato,ut_id: id }, + onComplete: function(transport) { + Element.replace('user_tools',transport.responseText); + update_list('action_listautenti.php?op=aggiorna'); + update_status('action_listautenti.php?op=aggiorna_status'); + } + }); +} + +function elimina_utente(id) +{ + if(confirm('')) + new Ajax.Request('action_listautenti.php', + { + method:'GET', + asynchronous:false, + parameters: {op:'elimina',ut_id: id }, + onComplete: function(transport) + { + $('person_dynamic').update(transport.responseText); + update_list('action_listautenti.php?op=aggiorna'); + update_status('action_listautenti.php?op=aggiorna_status'); + } + + }); +} + +function show_blank_user() +{ + new Ajax.Request('action_listautenti.php', + { + method:'GET', + parameters: {op:'blank'}, + onComplete: function(transport) + { + $('person_dynamic').update(transport.responseText); + } + }); +} + +function update_status(url) +{ + new Ajax.Request(url, + { + method:'GET', + onComplete: function(transport) + { + Element.replace('user_status_filter',transport.responseText); + } + }); +} + +function update_list_by_search(url) +{ + el=$('u_search') + pass=el.options[el.selectedIndex].value; + if (pass == "qu_id"){ + sel=$('u_select_qu') + val=sel.options[sel.selectedIndex].value; + + }else if (pass == "ut_dip"){ + sel=$('u_select_dip') + val=sel.options[sel.selectedIndex].value; + + }else + { + val=$('u_val').value + } + show_blank_user(); + + url=url+"&search="+pass+"&val="+val+"&type="+pass+"&sel="+val; + update_list(url); +} + +function update_select_search() +{ + el=$('u_search') + pass=el.options[el.selectedIndex].value; + if (pass == "qu_id"){ + + $('u_val').hide(); + $('u_select_dip').hide(); + $('u_select_qu').show(); + $('u_select_qu').selectedIndex=0; + + }else if(pass == "ut_dip"){ + + $('u_val').hide(); + $('u_select_qu').hide(); + $('u_select_dip').show(); + $('u_select_dip').selectedIndex=0; + + }else{ + + $('u_val').show(); + $('u_select_dip').hide(); + $('u_select_qu').hide(); + $('u_val').value=""; + + } + +} + +function show_report_menu(ty) +{ + + $('contenuto_reports').update(''); + $('contenuto_reports').hide(); + $('export_report_div').hide(); + + if(ty!='report_sovrannuali') + $('reports_anno').show(); + else $('reports_anno').hide(); + + new Ajax.Request('action_listareports.php', + { + method:'GET', + parameters: {op: 'menu', op2:ty }, + asynchronous:false, + onComplete: function(transport) + { + if($('current_report_ty').value!=null) + { + actualty=$('current_report_ty').value; + if(actualty!="" && $(actualty)!=null) + { + $(actualty).removeClassName('active_report'); + $(actualty).addClassName('viola'); + } + } + + $(ty).removeClassName('viola'); + $(ty).addClassName('active_report'); + $('current_report_ty').value=ty; + + $('contenuto_reports').hide(); + $('contenuto_reports').update(""); + $('show_reports').update(""); + $('show_reports').hide(); + $('show_reports').update(transport.responseText); + $('show_reports').show(); + } + }); + + switch (ty) + { + case 'report_sovrannuali': display_report('globale1A'); break; + case 'report_biblioteca': display_report('biblio2A'); break; + case 'report_utenti': display_report('utente3A'); break; + case 'export': display_report('export_biblio'); break; + case 'report_ente': display_report('ente'); break; + case 'report_progetto': display_report('progetto'); break; + } + +} + +function display_report(ty) +{ + $('export_report_div').hide(); + + if($('current_list')!=null) $('current_list').update(); + if($('report_head')!=null) $('report_head').remove(); + if($('current_report').value!=null) + { + actual=$('current_report').value; + if(actual!="" && $(actual)!=null) + { + $(actual).removeClassName('active_report'); + $(actual).addClassName('viola'); + } + } + + if(ty!=null && ty!="") + { + $(ty).removeClassName('viola'); + $(ty).addClassName('active_report'); + } + + $('current_report').value=ty; + + if($('reports_anno').visible()) + y=$('year_list').options[$('year_list').selectedIndex].value; + else y=''; + + new Ajax.Request('reports.php', + { + method:'GET', + parameters: {typegraph:ty,year:y }, + onComplete: function(transport) + { + $('contenuto_reports').hide(); + $('contenuto_reports').update(transport.responseText); + $('contenuto_reports').show(); + } + }); + + +} + +function sort_report(url) +{ + new Ajax.Request(url, + { + method:'GET', + onComplete: function(transport) + { + $('contenuto_reports').hide(); + $('contenuto_reports').update(transport.responseText); + $('contenuto_reports').show(); + } + }); +} + +function change_graph_by_year() +{ + if($('current_list')!=null) + $('current_list').update(""); + display_report($('current_report').value); +} + + +function choose_ISSN(){ + if (firstClick==1){ + firstClick=0; + if ($('ri_issn').value == '' || $('ri_issn')== null){ + ty=1; + } else { + ty=0; + } + + new Ajax.Request("modules/acnp_ISSN.php", { + method:'POST', + asynchronous: false, + parameters: {title:$('ri_titolopub').value, issn:$('ri_issn').value, by:ty}, + onComplete: function (transport){ + Dialog.info(transport.responseText, + {className: 'alphacube' , + destroyOnClose:true , + draggable:true , + width:800 , + maxHeight:500 , + recenterAuto: false , + showProgress: false , + showEffect: Effect.Appear, + showEffectOptions: {duration: 0.3} + }); + } + }); + } else { + passo2Borrowing(); + } +} + + + +function choose_ISBN(){ + if (firstClick==1){ + firstClick=0; + if ($('ri_isbn').value == '' || $('ri_isbn')== null){ + ty=1; + } else { + ty=0; + } + + new Ajax.Request("modules/sbn_ISBN.php", { + method:'POST', + asynchronous: false, + parameters: {title:$('ri_titolopub').value, isbn:$('ri_isbn').value, by:ty}, + onComplete: function (transport){ + Dialog.info(transport.responseText, + {className: 'alphacube' , + destroyOnClose:true , + draggable:true , + width:800 , + maxHeight:500 , + recenterAuto: false , + showProgress: false , + showEffect: Effect.Appear, + showEffectOptions: {duration: 0.3} + }); + } + }); + } else { + passo2Borrowing(); + } +} + +function changeHistorySearch(ty) +{ + clearHistoryResults() + $('search_form').update(""); + new Ajax.Request('action_storico.php', + { + method:'GET', + parameters: {tipo:ty,op:'changePanel'}, + onComplete: function(transport) + { + $('search_form').update(transport.responseText);; + } + }); +} + +//DIADOSIS TEAM submit history form on enter +jQuery(document).keypress(function(e) { + if(e.which == 13) { + if (jQuery('input[type=radio]:checked').size() > 0) { + jQuery('#big_right_arrow_btn_o')[0].click(); + } + } +}); + +function clearHistoryResults() +{ + if($('current_list')!=null) + $('current_list').update(""); + + if($('history_details')!=null) + $('history_details').update(""); +} + +function updateHistoryDDBiblioList(tiporich) +{ + clearHistoryResults() + + new Ajax.Request('action_storico.php', + { + method:'GET', + parameters: {tipobl:tiporich,op:'updateBiblioList'}, + onComplete: function(transport) + { + $('bibliosel').hide(); + Element.replace('bibliosel',transport.responseText); + $('bibliosel').show(); + } + }); +} + +function displayHistoryDDUteSearch(idx) +{ + clearHistoryResults() + if(idx==1) + { + $('searchute').show(); + } + else + { + $('nomeute').value=""; + $('searchute').hide(); + } +} + + +function historyDDSeach(ty) +{ + clearHistoryResults() + var param=$('history_form').serialize()+"&op=ricerca&tipo="+ty; + + req=new Ajax.Request('action_storico.php', + { + method:'POST', + parameters: param, + onComplete: function(transport) + { + + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + clear_incomplete_fields("history_form") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg); + break; + case "502": + clear_incomplete_fields("history_form") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg); + break; + case "201": + clear_incomplete_fields("history_form") + $('current_list').replace(res); + break; + + default: alert ("Error Ajax contact support:"+transport.responseText); + break; + } + } else alert ("Error Ajax contact support:"+transport.responseText); + } + }); +} + +function openHistoryDetails(id,t,tbl) +{ + new Ajax.Request('action_storico.php', + { + method:'GET', + parameters: { op: 'dettagliStorico',dd_id: id,tipo:t,tipobl:tbl }, + onComplete: function(transport) + { + Element.replace('my_request',transport.responseText); + if($('reports')) + $('reports').hide(); + + openFullRequestPanel(); + + } + + }); +} + +function reportsDetails(param) +{ + if($('current_list')!=null) + $('current_list').update(""); + var par=param+"&op=dettagliReport"; + + req=new Ajax.Request('action_storico.php', + { + method:'POST', + parameters: par, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "201": + if($('report_head')) $('report_head').remove(); + $('current_list').replace(res); + break; + + default: alert ("Error Ajax contact support:"+transport.responseText); + break; + } + } + } + }); +} + +function activeNilde4_biblio(idbib) { + var message = '
' + var articolo = '' + var count = 0; + + if (from3to4Save[0] != 1) + message = message+'
"My Account" ' + else + count=count+1; + if (from3to4Save[1] != 1) + message = message+ '
"My service" ' + else + count=count+1; + if (from3to4Save[2] != 1) + message = message+'
"My Catalog"' + else + count=count+1; + if (count == 2) + articolo = 'il pannello' + else + articolo = 'i pannelli' + + if (count == 3){ + new Ajax.Request('action_biblio.php', { method:'POST', + asynchronous: false, + parameters: {op:'from3to4',id:idbib}, + onComplete: function(transport){ + if (transport.responseText=='1'){ + + Dialog.alert('Continue', + {className: 'alphacube' , + destroyOnClose:true , + width:400 , + maxHeight:200 , + recenterAuto: false , + showProgress: false , + showEffect: Effect.Appear, + showEffectOptions: {duration: 0.3}, + ok: function(win){go('mynilde_panel.php?panel=borrowing');} + }); + + } + } + } + ); + } else + + Dialog.alert('You must save in order to continue '+articolo+message, + {className: 'alphacube' , + destroyOnClose:true , + width:400 , + maxHeight:200 , + recenterAuto: false , + showProgress: false , + showEffect: Effect.Appear, + showEffectOptions: {duration: 0.3} + }); +} + +function selected_users() +{ + var form = $('form_libusers') + var ut_check = form.getInputs('checkbox', 'idut[]') + var ok=false; + for (var i = 0; i < ut_check.length; i++) + { + if(ut_check[i].checked) + { + ok=true; + break; + } + } + if(!ok) negative_serv_feedback('') + return ok +} + + +var LAST_EDITED_DEP=""; + +function toggle_department_creator() +{ + $('department_creator').toggle(); +} + +function add_new_department() +{ + val=addslashes($('new_dep').getValue()); + req=new Ajax.Request("action_listautenti.php?op=newdep", + { + method:'POST', + parameters: { dip_nome: eval("'"+val+"'")}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "200": + $('new_dep').value="";; + $('department_creator').update(res); + _reload_list_department(); + break; + + case "501": + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + case "503": + if (confirm('')) + activate_department(msg); + break; + default: alert("error:"+transport.responseText); + } + } + else alert("error:"+transport.responseText); + } + + }); +} + +function activate_department(did) +{ + req=new Ajax.Request("action_listautenti.php?op=activatedep", + { + method:'POST', + parameters: { dip_id: did }, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "200": + $('new_dep').value="";; + $('department_creator').update(res); + _reload_list_department(); + break; + default: alert("error:"+transport.responseText); + } + } + else alert("error:"+transport.responseText); + } + }); +} + +function delete_department(lid) +{ + if(confirm('')) + { + req=new Ajax.Request("action_listautenti.php?op=deletedep", + { + method:'POST', + parameters: { dip_id: lid}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "200": + $('department_creator').update(res); + _reload_list_department(); + break; + + case "501": + negative_serv_feedback(msg) + break; + + default: alert("error:"+transport.responseText); break; + } + } + else alert("error:"+transport.responseText); + } + + }); + } +} + +function rename_department(id) +{ + + req=new Ajax.Request("action_listautenti.php?op=renamedepartment", + { + method:'POST', + parameters: { dip_id: id}, + onComplete: function(transport) + { + if(LAST_EDITED_DEP!="") undo_edit_department(LAST_EDITED_DEP); + + $("dep_"+id).addClassName("edit_dep_row"); + $("dep_"+id).update(transport.responseText); + $("edit_dep_"+id).focus(); + LAST_EDITED_LABEL=id; + + } + }); + +} + +function update_department(id) +{ + val=$('edit_dep_'+id).getValue(); + + if(val!="") + { + if(confirm('')) + { + req=new Ajax.Request("action_listautenti.php?op=updatedep", + { + method:'POST', + parameters: { dip_id: id, dip_nome: val}, + onComplete: function(transport) + { + + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "201": + $("dep_"+id).removeClassName("edit_dep_row"); + $("dep_"+id).update(res); + update_list('action_listautenti.php?op=aggiorna'); + LAST_EDITED_DEP=""; + break; + + case "202": undo_rename_department(id) + break; + + case "501": + negative_serv_feedback(msg) + break; + case "502": + negative_serv_feedback(msg) + break; + } + } + else alert ("Error Ajax contact support:"+transport.responseText); + } + + }); + } + else undo_rename_department(id); + } + else + { + negative_serv_feedback(''); + undo_rename_department(id); + } +} + + +function undo_rename_department(id) +{ + req=new Ajax.Request("action_listautenti.php?op=restoredep", + { + method:'POST', + asynchronous: false, + parameters: { dip_id: id}, + onComplete: function(transport) + { + $("dep_"+id).removeClassName("edit_dep_row"); + $("dep_"+id).update(transport.responseText); + LAST_EDITED_DEP=""; + } + + }); +} + + +function apply_department(iddip) +{ + if(selected_users() && confirm('')) + { + var param=$('form_libusers').serialize()+"&op=applydep&dip_id="+iddip; + + req=new Ajax.Request("action_listautenti.php", + { + method:'POST', + parameters: param, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + + switch (statusResp) + { + case "201": + $('current_list').update(res); + positive_serv_feedback(msg) + break; + + case "501": + negative_serv_feedback(msg) + break; + } + } + } + }); + } +} + + + +function _reload_list_department() +{ + + req=new Ajax.Request("action_listautenti.php", + { + method:'POST', + parameters: 'op=reloaddep', + onComplete: function(transport) + { + $('u_select_dip').update(transport.responseText); + + } + }); + +} + +function cerca_titoloEsatto(url,title){ + if (firstClick==1){ + firstClick=0; + req=new Ajax.Request(url, + { + method:'POST', + parameters: {title:title, by:2}, + onComplete: function(transport) + { + $('modal_dialog_message').update(transport.responseText); + + } + }); + + } +} + +function showInformaUteButton() +{ + $('dd_costofuorinilde').value=$('dd_costofuorinilde').value.replace(",","."); + if($('dd_costofuorinilde').value==""||isNaN($('dd_costofuorinilde').value)) + $('dd_costofuorinilde').value=0; + + costo=parseFloat($('dd_costofuorinilde').value); + if(costo>0) + { + if(!$('big_btn_infouser').visible()) + { + $('big_btn_plain_v').hide(); + $('big_btn_infouser').show() + } + } + else + { + $('big_btn_infouser').hide() + $('big_btn_plain_v').show(); + } +} + +function clean_borrowing_session() +{ + new Ajax.Request('action_borrowing.php', + { + method:'GET', + parameters: {op:'clean_req_session'}, + onComplete: function(transport) {} + }); +} + +function clean_lending_session() +{ + new Ajax.Request('action_lending.php', + { + method:'GET', + parameters: {op:'clean_req_session'}, + onComplete: function(transport) {} + }); +} + +function download_report(url) +{ + $('export_report_div').hide(); + $('export_report_div').update(''); + new Ajax.Request(url, + { + method:'GET', + onCreate: function(transport) + { + $('export_report_div').update('
'); + $('export_report_div').show(); + }, + onComplete: function(transport) + { + $('export_report_div').update(transport.responseText); + } + }); +} + + +function start_upload_lending() +{ + var nfiles=0; + var nomef= $('fname').value + + var uploader = new qq.FileUploader({ + element: document.getElementById('file-uploader'), + + action: 'modules/uploader.php', + + params: { + fname: nomef + }, + + template: '
' + + '
' + + '
' + + '
    ' + + '
    ' + + '
    ' + + '

    ', + + fileTemplate: '
  • File: ' + + '' + + '' + + '' + + '' + + ':' + + '
  • ', + + multiple: false, + + debug: false, + + onSubmit: function(id, fileName) + { + if(nfiles==0) + { + if($('UploadList')!=null) + { + $("UploadList").update(""); + $('msgpanel').update(""); + } + return true; + } + else + { + negative_serv_feedback("") + return false; + } + + }, + onProgress: function(id, fileName, loaded, total){ }, + onComplete: function(id, fileName, responseJSON) + { + if(responseJSON["success"]==true) + { + nfiles++; + this.showMessage('',0); + + $('qq-upload-button').hide(); + $('big_btn_plain_g').show(); + $('delivery_type').hide() + $('dd_file').value=responseJSON["filename"]; + + } + else + this.showMessage(responseJSON["error"],1); + + }, + onCancel: function(id, fileName){ nfiles=0;}, + + messages: { + typeError: "{file} has invalid extension. Only {extensions} are allowed.", + sizeError: "{file} is too large, maximum file size is {sizeLimit}.", + minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.", + emptyError: "{file} is empty, please select files again without it.", + onLeave: "The files are being uploaded, if you leave now the upload will be cancelled." + }, + showMessage: function(message,error) + { + if(error==1) + { + if($('msgpanel').hasClassName('correct')) $('msgpanel').removeClassName('correct'); + + $('msgpanel').addClassName('error'); + } + else + { + if($('msgpanel').hasClassName('error')) $('msgpanel').removeClassName('error'); + + $('msgpanel').addClassName('correct'); + } + + $('msgpanel').update(message); + } +}); +} + +// DIADOSIS TEAM Add function start_upload_borrowing +function start_upload_borrowing() +{ + document.getElementById('big_left_arrow_btn_g').hide(); + var nfiles=0; + var nomef= $('fname').value + var uploader = new qq.FileUploader({ + element: document.getElementById('file-uploader'), + action: 'modules/uploader.php', + + params: { + fname: nomef + }, + + template: '
    ' + + '
    ' + + '
    ' + + '
      ' + + '
      ' + + '
      ' + + '

      ', + + fileTemplate: '
    • File: ' + + '' + + '' + + '' + + '' + + ':' + + '
    • ', + + multiple: false, + + debug: false, + + onSubmit: function(id, fileName) + { + if(nfiles==0) + { + if($('UploadList')!=null) + { + $("UploadList").update(""); + $('msgpanel').update(""); + } + return true; + } + else + { + nfiles=0; + if($('UploadList')!=null) + { + $("UploadList").update(""); + $('msgpanel').update(""); + } + return true; + } + + }, + onProgress: function(id, fileName, loaded, total){ }, + onComplete: function(id, fileName, responseJSON) + { + if(responseJSON["success"]==true) + { + nfiles++; + this.showMessage('',0); + document.getElementById('big_left_arrow_btn_g').show(); + document.getElementById('dd_file').value=responseJSON["filename"]; + + } + else + this.showMessage(responseJSON["error"],1); + + }, + onCancel: function(id, fileName){ nfiles=0;}, + + messages: { + typeError: "{file} has invalid extension. Only {extensions} are allowed.", + sizeError: "{file} is too large, maximum file size is {sizeLimit}.", + minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.", + emptyError: "{file} is empty, please select files again without it.", + onLeave: "The files are being uploaded, if you leave now the upload will be cancelled." + }, + showMessage: function(message,error) + { + if(error==1) + { + if($('msgpanel').hasClassName('correct')) $('msgpanel').removeClassName('correct'); + + $('msgpanel').addClassName('error'); + } + else + { + if($('msgpanel').hasClassName('error')) $('msgpanel').removeClassName('error'); + + $('msgpanel').addClassName('correct'); + } + + $('msgpanel').update(message); + } +}); +} + + + +function read_biblio_info(bid,id_tip){ + var g=new Tip('library_link_'+id_tip, { + ajax: { + url: 'action_listaborrowing.php?op=library&bibid='+bid, + options: {method: 'GET'} + }, + title: '', + style: 'nilde_user' + } + + ); + $('library_link_'+id_tip).prototip.show(); + +} + +function read_bib_lending(id_tip){ + var g=new Tip('bi_nome', { + ajax: { + url: 'action_listalending.php?op=library&bibid='+id_tip, + options: {method: 'GET'} + }, + title: '', + style: 'nilde_user' + } + + ); + $('bi_nome').prototip.show(); + +} + +function read_rich_sett(id_tip){ + var g=new Tip('rich_sett_link_'+id_tip, { + ajax: { + url: 'action_borrowing.php?op=rich_settimanali&idforni='+id_tip, + options: {method: 'GET'} + }, + title: '', + style: 'nilde_info' + } + + ); + $('rich_sett_link_'+id_tip).prototip.show(); + +} + +function read_user_info(uid,id_tip){ + var g=new Tip('usr_link_'+id_tip, { + ajax: { + url: 'action_listaborrowing.php?op=user&utente='+uid, + options: {method: 'GET'} + }, + title: '', + style: 'nilde_user' + } + + ); + $('usr_link_'+id_tip).prototip.show(); + +} + +function read_tooltip(id){ + var t=new Tip('tip_'+id, { + ajax: { + url: 'action_listaborrowing.php?op=read_postit&id='+id, + options: { method: 'GET' } + }, + title: '', + style: 'nilde_note' + } + ); + $('tip_'+id).prototip.show(); +} + +function salvaPostit(id) +{ + var form=$('postit_'+id).serialize(true); + var x= new Ajax.Request("action_listaborrowing.php", + { + method: 'POST', + parameters: form, + onComplete: function(transport) + { + if(transport.responseText==0) + $('img_tip_'+id).src="images/edit_note.png"; + else + $('img_tip_'+id).src="images/note.png"; + + } + }); +} + function cancPostit(id) + { + $('nota_txt_'+id).value = ''; + + } + \ No newline at end of file diff --git a/scripts/ajax_engine_user.php b/scripts/ajax_engine_user.php new file mode 100755 index 0000000..e7af63b --- /dev/null +++ b/scripts/ajax_engine_user.php @@ -0,0 +1,1472 @@ +var from3to4SaveUte=0 + +function showAccount() +{ + if($('account_display_trigger_box').visible()){ + $('expand_account').toggleClassName('expand_v_up'); + }else{ + $('expand_account').toggleClassName('expand_v_down'); + } + $('account_infos').toggle(); + + if($('expand_account').hasClassName('expand_v_up')) + $('account_news').hide(); + else + $('account_news').show(); + +} + + + +function editAccount(url) +{ + req=new Ajax.Request(url, + { + method:'POST', + parameters: $('form_utente').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + + switch (statusResp) + { + case "201": + $('person_dynamic').update(res); + from3to4SaveUte=1 + positive_account_feedback(msg) + break; + + case "501": + case "502": + clear_incomplete_fields("form_utente") + show_incomplete_fields(values["fields"]); + negative_account_feedback(msg) + break; + + case "503": + $('person_dynamic').update(res); + negative_account_feedback(msg) + break; + } + } + else + { + $('person_dynamic').update(transport.responseText); + } + } + }); +} + +function undo_account_edit() +{ + if(confirm('')) + { + new Ajax.Request("action_utente.php?op=undoedit", + { + method:'GET', + onComplete: function (transport) + { + $('person_dynamic').update(transport.responseText); + $('expand_account').href="javascript:showAccount()"; + } + }); + } +} + +function modifica_account() +{ + $('expand_account').href="javascript:resetta_account()"; + document.form_utente.submit() +} + +function salva_account() +{ + document.form_utente.submit() + $('expand_account').href="javascript:showAccount()"; +} + +function resetta_account() +{ + if(confirm('')) + { + new Ajax.Request("action_utente.php?op=undoedit", + { + method:'GET', + onComplete: function (transport) + { + $('person_dynamic').update(transport.responseText); + $('expand_account').href="javascript:showAccount()"; + showAccount() + } + }); + } + +} + +function reg_step(step) +{ + var param=$('form_reg_ute').serialize()+"&op=next_step&step="+step; + req=new Ajax.Request("action_utente.php", + { + method:'POST', + parameters: param, + onComplete: + function(transport) + { + + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "501": + clear_incomplete_fields("form_reg_ute") + show_incomplete_fields(values["fields"]); + registration_feedback(msg) + break; + + case "502": + registration_feedback(msg) + break; + + case "503": + clear_incomplete_fields("form_reg_ute") + show_incomplete_fields(values["fields"]); + registration_feedback(msg) + break; + + case "201": + clear_incomplete_fields("form_reg_ute") + res = res.replace("id=\"ut_nome\" value=\"\"", "id=\"ut_nome\" value=\"getShibValue("Shib-Person-givenName"); ?>\" readonly"); + res = res.replace("id=\"ut_cognome\" value=\"\"", "id=\"ut_cognome\" value=\"getShibValue("Shib-Person-sn"); ?>\" readonly"); + res = res.replace("id=\"ut_email\" value=\"\"", "id=\"ut_email\" value=\"getShibValue("Shib-Person-mail"); ?>\" readonly"); + res = res.replace("id=\"ut_tel_1_pre\" value=\"\"", "id=\"ut_tel_1_pre\" value=\"getShibValue("Shib-Person-telephoneNumber"), 0,3); ?>\" readonly"); + res = res.replace("id=\"ut_tel_1_num\" value=\"\"", "id=\"ut_tel_1_num\" value=\"getShibValue("Shib-Person-telephoneNumber"), 3); ?>\" readonly"); + res = res.replace("id=\"ut_tel_1_num\" value=\"\"", "id=\"ut_tel_1_num\" value=\"getShibValue("Shib-Person-telephoneNumber"), 3); ?>\" readonly"); + + $('public_area').update(res); + + break; + } + } + else + { + alert ("Ajax Error. Contact Tech support:"+transport.responseText) + $('public_area').update(transport.responseText); + } + } + }); +} + +function reg_prev_step(step) { + new Ajax.Request("action_utente.php", + { + method:'POST', + parameters: { op: 'prev_step', step: step}, + onComplete: function (transport) { + $('public_area').update(transport.responseText); + } + }); +} + +function change_library() { + new Ajax.Request("action_utente.php", + { + method:'POST', + parameters: { op: 'change_library'}, + onComplete: function (transport) { + $('public_area').update(transport.responseText); + } + }); +} + + +function show_library_selection_box(rad) +{ + if($('biblio_select_list_box') && $('biblio_select_list_box').visible) $('biblio_select_list_box').hide(); + switch (rad.value) + { + case "1": $('loc_select').selectedIndex=0; + $('biblio_select_by_location').show(); + $('biblio_select_by_term').hide(); + $('biblio_select_by_institution').hide(); + $('inst_select').hide(); + break; + + case "2": $('inst_type_select').selectedIndex=0 + $('inst_select').selectedIndex=0 + $('biblio_select_by_institution').show(); + $('biblio_select_by_location').hide(); + $('biblio_select_by_term').hide(); + break; + + case "3": $('biblio_select_by_term').show(); + $('biblio_select_by_location').hide(); + $('biblio_select_by_institution').hide(); + $('inst_select').hide(); + break; + } +} + +function filterLibrary() +{ + + var form = $('form_reg_ute'); + var radio = form['radio_sel']; + var nation = $('na_id').value; + + if ( ($('biblio_select_by_location').visible() && $('loc_select').selectedIndex==0) || + ( $('biblio_select_by_institution').visible() && ( $('inst_type_select').selectedIndex==0 || $('inst_select').selectedIndex==0 )) + ) + { + $('biblio_select_list_box').update(); + return; + } + new Ajax.Request("action_utente.php?op=filterLibrary&nation="+nation, + { + method:'POST', + parameters: $('form_reg_ute').serialize(true), + onComplete: function(transport) + { + if(transport.responseText!="") + { + $('biblio_select_list_box').update(transport.responseText); + $('biblio_select_list_box').show(); + } + } + }); +} + +function updateInst() +{ + + $('biblio_select_list_box').update(); + if($('inst_type_select').selectedIndex!=0) + { + new Ajax.Request("action_utente.php?op=filterInst", + { + method:'POST', + parameters: $('form_reg_ute').serialize(true), + onComplete: function(transport) + { + if(transport.responseText!="") + { + $('inst_select').update(transport.responseText); + $('inst_select').show(); + } + } + }); + } + else { + $('inst_select').hide(); + } + +} + +function updateNation() +{ + var nation = $('na_id').value; + + $('biblio_select').update(); + new Ajax.Request("action_utente.php?op=UpdateNation&nation="+nation, + { + method:'POST', + parameters: $('form_reg_ute').serialize(true), + onComplete: function(transport) + { + if(transport.responseText!="") + { + $('biblio_select').update(transport.responseText); + $('biblio_select').show(); + } + } + }); + + +} + + +function account_feedback_visible() +{ + goTop(); + return show_feedback('account_feedback'); +} + +function hide_account_feedback() +{ + hide_feedback('account_feedback'); +} + +function update_account_feedback(msg) +{ + update_feedback('account_feedback',msg); + goTop(); +} + +function positive_account_feedback(msg) +{ + positive_feedback('account_feedback',msg); +} + + +function negative_account_feedback(msg) +{ + negative_feedback('account_feedback',msg); +} + +function registration_feedback(msg) +{ + $('registration_feedback').update(msg); + if(!$('registration_feedback').hasClassName('red')) + $('registration_feedback').addClassName("red"); + goTop(); +} + +function showReferenceManager() +{ + if($('history_dd').visible()) $('history_dd').hide(); + if($('reports').visible()) $('reports').hide(); + $('reference_manager').show(); +} + +function showHistoryDD() +{ + if($('reference_manager').visible()) + $('reference_manager').hide(); + if($('reports').visible()) + $('reports').hide(); + + loadHistoryDD(); + $('history_dd').show(); +} + +function showReports() +{ + if($('reference_manager').visible()) + $('reference_manager').hide(); + if($('history_dd').visible()) + $('history_dd').hide(); + $('reports').show(); +} + +function OpenURLLayout() +{ + +} + +function edit_file(fileobj) +{ + + var form = $('form_riferimento'); + var el=form[fileobj+"_old"]; + Form.Element.clear(el); + $(fileobj+"_label").update(""); + $(fileobj).show(); + $('rm_file_edit_btn').hide(); +} + +function selected_references() +{ + var form = $('form_bibliografia') + var rif_check = form.getInputs('checkbox', 'idrif[]') + var ok=false; + for (var i = 0; i < rif_check.length; i++) + { + if(rif_check[i].checked) + { + ok=true; + break; + } + } + if(!ok) negative_serv_feedback('') + return ok +} + +function closeReferencePanel_noconfirm() +{ +$('reference_box').setStyle({ + position: 'absolute', + left: '-45%', + }); + if($('expand_o').visible()) $('expand_o').hide(); + if($('discard_o').visible()) $('discard_o').hide(); + + $('my_reference').update(""); + $('my_reference').hide(); + resetReferencePanel(); + if(!$('reference_list_tools').visible()) + $('reference_list_tools').show(); + if(!$('current_list').visible()) + $('current_list').show(); + $('form_bibliografia').setStyle({ + height: 'auto' + }); + + clearSelectedRow(); + clean_refman_session(); +} + +function closeReferencePanel() +{ + var conf=true; + if($('discard_o').visible()) + { + conf=confirm(''); + } + + if(conf) + { + $('reference_box').setStyle({ + position: 'absolute', + }); + + $('pillow2').setStyle({ + width: '97%' + }); + + if($('expand_o').visible()) $('expand_o').hide(); + if($('discard_o').visible()) $('discard_o').hide(); + + $('my_reference').update(""); + $('my_reference').hide(); + resetReferencePanel(); + + if(!$('reference_list_tools').visible()) + $('reference_list_tools').show(); + if(!$('current_list').visible()) + $('current_list').show(); + + $('form_bibliografia').setStyle({ + height: 'auto' + }); + + clearSelectedRow(); + clean_refman_session(); + } +} + +function directCloseReferencePanel() +{ + var conf=true; + if($('discard_o').visible()) + { + conf=confirm(''); + } + + if(conf) + { + $('reference_box').setStyle({ + position: 'absolute', + }); + + $('pillow2').setStyle({ + width: '97%' + }); + + if($('expand_o').visible()) $('expand_o').hide(); + if($('discard_o').visible()) $('discard_o').hide(); + + $('my_reference').update(""); + $('my_reference').hide(); + resetReferencePanel(); + + if(!$('reference_list_tools').visible()) + $('reference_list_tools').show(); + if(!$('current_list').visible()) + $('current_list').show(); + + $('form_bibliografia').setStyle({ + height: 'auto' + }); + + clearSelectedRow(); + } +} + + +function blankReference() +{ + new Ajax.Updater('my_reference', "action_refman.php", + { + method:'GET', + asynchronous: false, + parameters: { op: 'blank_reference' } + }); +} + +function resetReferencePanel() +{ + blankReference(); +} + +function openFullReferencePanel() +{ + close_dd_details() + $('reference_list_tools').hide(); + $('current_list').hide(); + + if($('label_creator').visible()) toggle_label_creator(); + + $('pillow2').setStyle({ + }); + + $('reference_box').setStyle({ + position: 'relative', + marginLeft: '0' + }); + + $('expand_o').hide(); + $('discard_o').show(); + $('my_reference').show() +} + +function openReferencePanel() +{ + goServTop(); + $('expand_o').show(); + $('reference_box').setStyle({ + position: 'relative', + }); + + if(!$('expand_o').hasClassName("expand_o_left")) + { + $('expand_o').removeClassName('expand_o_right'); + $('expand_o').toggleClassName('expand_o_left'); + $('expand_o').href="javascript:closeReferencePanel()"; + } + + $('reference_list_tools').show(); + $('current_list').show(); + + $('expand_o').show(); + + if($('discard_o').visible()) + $('discard_o').hide(); + + $('form_bibliografia').setStyle({ + height: 'auto' + }); + $('my_reference').show() +} + +function nuovoRiferimento(ty) +{ + url = 'action_refman.php' + + if (ty == 30) { + clean_refman_session(); + ty = 1; + } + + if (ty > 0) { + //DIADOSIS TEAM + var doi = document.getElementById("doi_sent").value.trim(); + + // Remove whitespaces from doi string + doi = doi.replace(/\s+/g, ''); + + // Remove http(s)://dx.doi.org/ or doi: or DOI: from doi beginning if it exists or PMID: if it is pmid + + if (doi.include("PMID") || doi.include("pmid" || doi.isNumber())) { + if (doi.substr(0, 5) == 'PMID:' || doi.substr(0, 5) == 'pmid:') + doi = doi.substr(5); + } + else if (doi.include("DOI:") || doi.include("doi:")) { + if (doi.substr(0, 4) == 'DOI:' || doi.substr(0, 4) == 'doi:') + doi = doi.substr(4); + } + else { + if (doi.substr(0, 19) == 'https://dx.doi.org/') + doi = doi.substr(19); + if (doi.substr(0, 18) == 'http://dx.doi.org/') + doi = doi.substr(18); + } + + req = new Ajax.Request(url, + { + method: 'GET', + parameters: {op: 'new_rif', tipomat: eval(ty), doi: doi}, + onComplete: function (transport) + { + if (isAjaxXMLRequest(req)) + { + values = parseXMLResponse(transport); + statusResp = values["status"]; + res = values["content"]; + msg = values["msg"]; + switch (statusResp) + { + case "501": + go("error.php?msg=" + encodeURI(msg)); + break; + default: + alert("ERROR MULTIPLE REQUESTS: Contact Administrator"); + break; + } + } + else + { + $('my_reference').update(transport.responseText); + openFullReferencePanel(); + } + } + }); + } + else + { + + $('my_reference').update(""); + req = new Ajax.Request(url, + { + method: 'GET', + parameters: {op: 'new_rif'}, + onComplete: function (transport) + { + if (isAjaxXMLRequest(req)) + { + values = parseXMLResponse(transport); + statusResp = values["status"]; + res = values["content"]; + msg = values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg=" + encodeURI(msg)); + break; + default: + alert("ERROR MULTIPLE REQUESTS: Contact Administrator"); + break; + } + } + else + { + $('my_reference').update(transport.responseText); + openFullReferencePanel(); + } + } + }); + + + } + + +} + +// DIADOSIS TEAM +function validateDOI(ty){ + var doi=document.getElementById("doi_sent").value.trim(); + var re = /\b10\.(\d+\.*)+[\/](([^\s\.])+\.*)+\b/; + var re_pm = /\bPMID:/; + var re_pm_2 = /\pmid:/; + var re_pm_3 = /^\d+$/; + + doi = doi.replace(/\s+/g, ''); + + // Remove https://dx.doi.org/ from doi beginning if it exists + if (doi.substr(0,19) == 'https://dx.doi.org/') + doi = doi.substr(19); + + // Remove http://dx.doi.org/ from doi beginning if it exists + if (doi.substr(0,18) == 'http://dx.doi.org/') + doi = doi.substr(18); + + if (re.test(doi) || re_pm.test(doi) || re_pm_2.test(doi) || re_pm_3.test(doi) ) + nuovoRiferimento(ty); + else + negative_serv_feedback('') + +} + +//DIADOSIS TEAM submit DOI form on enter +jQuery(document).keypress(function(e) { + if(e.which == 13) { + if (jQuery("#doi_sent").is(':focus')) { + + jQuery('#big_right_arrow_btn_o')[0].click(); +} + + } +}); + +function nuovoRiferimentoByOpenURL(openurl) +{ + req=new Ajax.Request("action_refman.php?"+openurl, + { + method:'GET', + parameters: { op: 'new_rif_openurl' }, + onComplete: function (transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + default: alert("ERRORE RICHIESTE MULTIPLE: contattare l'amministratore"); break; + } + } + else + { + $('my_reference').update(transport.responseText); + } + } + }); +} + +function openFullReferencePanelByOpenURL(url) +{ + req=new Ajax.Request("action_refman.php?"+url, + { + method:'GET', + parameters: { op: 'openByOpenurl' }, + onComplete: function (transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encoddeURI(msg)); + break; + default: alert("ERRORE RICHIESTE MULTIPLE: contattare l'amministratore"); break; + } + } + else + { + $('my_reference').update(transport.responseText); + openFullReferencePanel(); + } + } + }); +} + +function salvaRiferimento() +{ + openFullReferencePanel() + if($('rm_file')!=null) + $('rm_file_old').value=$('rm_file').value; + + document.form_riferimento.op.value="save"; + document.form_riferimento.submit(); +} + +function salvarichiediRiferimento() +{ + openFullReferencePanel() + if($('rm_file')!=null) + $('rm_file_old').value=$('rm_file').value; + document.form_riferimento.op.value="save_req"; + document.form_riferimento.submit(); +} + +function aggiornaRiferimento() +{ + openFullReferencePanel() + if($('rm_file')!=null) + $('rm_file_old').value=$('rm_file').value; + document.form_riferimento.op.value="update"; + document.form_riferimento.submit(); +} + +function aggiornarichiediRiferimento() +{ + openFullReferencePanel() + if($('rm_file')!=null) + $('rm_file_old').value=$('rm_file').value; + document.form_riferimento.op.value="update_req"; + document.form_riferimento.submit(); +} + +function modifica_riferimento() +{ + req1=new Ajax.Request('action_refman.php', + { + method:'GET', + parameters: { op: 'check_edit_session' }, + onComplete: function (transport) + { + + if(isAjaxXMLRequest(req1)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + case "201": + openFullReferencePanel() + document.form_riferimento.submit(); + break; + } + } + } + }); +} + + +function apriRiferimento(id) +{ + req=new Ajax.Request('action_refman.php', + { + method:'GET', + parameters: { op: 'vis_rif',ri_id: id }, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + default: alert("ERRORE RICHIESTE MULTIPLE: contattare l'amministratore"); break; + } + } + else + { + close_dd_details(); + + selectRifRow(id); + $('my_reference').update(transport.responseText) + openReferencePanel(); + } + } + + }); +} + +function richiediRiferimento(id, but) +{ + if (but === 100) + { + clean_refman_session(); + } + + url='action_refman.php' + req=new Ajax.Request(url, + { + method:'POST', + parameters: { op: 'ric_rif',rid:id}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "501": + go("error.php?msg="+encodeURI(msg)); + break; + default: alert("ERRORE RICHIESTE MULTIPLE: contattare l'amministratore"); break; + } + } + else + { + selectRifRow(id); + $('my_reference').update(transport.responseText) + openFullReferencePanel(); + } + } + + }); + +} + +function editRiferimento(url) +{ + req=new Ajax.Request(url, + { + method:'POST', + parameters: $('form_riferimento').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + + case "201": + + case "202": + + case "203": + + case "207": + $('my_reference').update(res); + if($('viewmode').value=='1') openReferencePanel() + $('reference_manager').show(); + update_references(); + positive_serv_feedback(msg) + break; + + case "501": + clear_incomplete_fields("form_riferimento") + show_incomplete_fields(values["fields"]); + negative_serv_feedback(msg) + break; + + case "502": + $('reference_manager').hide(); + $('my_reference').update(res); + if($('viewmode').value=='1') openReferencePanel() + $('reference_manager').show(); + negative_serv_feedback(msg) + break; + + case "504": + negative_serv_feedback(msg) + break; + + case "505": + $('my_reference').update(res); + if($('viewmode').value=='1') openReferencePanel() + $('reference_manager').show(); + update_references(); + negative_serv_feedback(msg) + break; + case "555": + closeReferencePanel_noconfirm(); + update_references(); + negative_serv_feedback(msg) + break; + + default: alert(transport.responseText); + } + + } + else + { + + $('reference_manager').hide(); + $('my_reference').update(transport.responseText); + + if($('viewmode').value=='1') openReferencePanel() + + $('reference_manager').show(); + } + } + }); +} + +function rispostaFN(risp,id) +{ + url='action_refman.php' + new Ajax.Request(url, + { + method:'GET', + parameters: { op: 'rispostaFN',risp: risp ,ri_id: id}, + onComplete: function(transport) + { + Element.replace('reference_dd',transport.responseText); + update_references(); + openReferencePanel(); + } + + }); + +} + +function toggle_dd_details() +{ + if($('my_reference').visible()) directCloseReferencePanel() + + elems=$('current_list').select('[class="dd_infos"]') + + for (var i = 0; i < elems.length; i++) + { + elems[i].toggle(); + } + + $('sort_by_bi_idrichie').toggle(); + + if($('expand_o2_t').hasClassName('expand_o2_left_t')) + { + $('expand_o2_t').removeClassName('expand_o2_left_t'); + $('expand_o2_t').toggleClassName('expand_o2_right_t'); + } + else if($('expand_o2_t').hasClassName('expand_o2_right_t')) + { + $('expand_o2_t').removeClassName('expand_o2_right_t'); + $('expand_o2_t').toggleClassName('expand_o2_left_t'); + } + if($('expand_o2_b').hasClassName('expand_o2_left_b')) + { + $('expand_o2_b').removeClassName('expand_o2_left_b'); + $('expand_o2_b').toggleClassName('expand_o2_right_b'); + } + else if($('expand_o2_b').hasClassName('expand_o2_right_b')) + { + $('expand_o2_b').removeClassName('expand_o2_right_b'); + $('expand_o2_b').toggleClassName('expand_o2_left_b'); + } + +} + +function close_dd_details() +{ + if($('sort_by_bi_idrichie').visible()) + toggle_dd_details(); +} + +function update_references(url) +{ + dd_stato=0 + if ($('sort_by_bi_idrichie').visible()) dd_stato=1 + + if(!url || url=="" || url==null) + url="action_bibliografia.php?op=aggiorna"; + + new Ajax.Request(url, + { + method:'GET', + asynchronous:false, + parameters: { dddetails: eval(dd_stato) }, + onComplete: function(transport) + { + $('current_list').update(transport.responseText); + } + }); + +} + +function update_references_by_range(url) +{ + el=$('passo') + pass=el.options[el.selectedIndex].value; + + dd_stato=0 + if ($('sort_by_bi_idrichie').visible()) dd_stato=1 + + url=url+"&dddetails="+eval(dd_stato) + + new Ajax.Updater('current_list', url, + { + method:'GET', + asynchronous:false, + parameters: {passo: eval(pass)} + }); +} + +function update_references_by_label(url) +{ + el=$('label') + label=el.options[el.selectedIndex].value; + + dd_stato=0 + if ($('sort_by_bi_idrichie').visible()) dd_stato=1 + + url=url+"&dddetails="+eval(dd_stato) + + new Ajax.Updater('current_list', url, + { + method:'GET', + asynchronous:false, + parameters: {label: eval(label)} + }); +} + + +function delete_selected(url) +{ + dd_stato=0 + + if ($('sort_by_bi_idrichie').visible()) dd_stato=1 + + url=url+"&dddetails="+eval(dd_stato) + + if(selected_references()) + { + if(confirm('')) + { + req=new Ajax.Request(url, + { + method:'POST', + parameters: $('form_bibliografia').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) { + case "201": + positive_serv_feedback(msg) + break; + + case "501": + negative_serv_feedback(msg) + break; + } + $('current_list').update(res); + } + else + { + $('current_list').update(transport.responseText); + } + resetReferencePanel(); + } + }); + } + } +} + +var LAST_EDITED_LABEL=""; + +function link_label(url) +{ + dd_stato=0 + if ($('sort_by_bi_idrichie').visible()) dd_stato=1 + + url=url+"&dddetails="+eval(dd_stato) + + if(selected_references()) + { + req=new Ajax.Request(url, + { + method:'POST', + parameters: $('form_bibliografia').serialize(true), + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + res=values["content"]; + msg=values["msg"]; + switch (statusResp) + { + case "201": + $('current_list').update(res); + + update_reference_labels(); + + positive_serv_feedback(msg) + break; + + case "501": + $('current_list').update(res); + negative_serv_feedback(msg) + break; + + case "502": + $('current_list').update(res); + negative_serv_feedback(msg) + break; + } + } + else + { + $('current_list').update(transport.responseText); + } + } + }); + } +} + +function add_new_label() +{ + val=$('new_label').getValue(); + req=new Ajax.Request("action_etichetta.php?op=new", + { + method:'POST', + parameters: { et_nome: eval("'"+val+"'")}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + switch (statusResp) + { + case "201": + + update_labels(); + update_reference_labels(); + positive_serv_feedback('') + break; + case "501": + negative_serv_feedback('') + break; + case "502": + negative_serv_feedback('') + break; + } + + } + } + + }); + + +} + +function delete_label(lid) +{ + dd_stato=0 + if ($('sort_by_bi_idrichie').visible()) dd_stato=1 + + if(confirm('')) + { + req=new Ajax.Request("action_etichetta.php?op=delete", + { + method:'POST', + parameters: { et_id: lid}, + onComplete: function(transport) + { + update_labels() + update_references("action_bibliografia.php?op=aggiorna&labeldel="+lid+"&dddetails="+eval(dd_stato)); + update_reference_labels(); + positive_serv_feedback('') + } + + }); + } +} + +function edit_label(lid) +{ + req=new Ajax.Request("action_etichetta.php?op=edit", + { + method:'POST', + parameters: { et_id: lid}, + onComplete: function(transport) + { + if(LAST_EDITED_LABEL!="") undo_edit_label(LAST_EDITED_LABEL); + + $("label_"+lid).addClassName("edit_label_row"); + $("label_"+lid).update(transport.responseText); + $("edit_label_"+lid).focus(); + LAST_EDITED_LABEL=lid; + + } + }); + +} + +function update_label(lid) +{ + val=$('edit_label_'+lid).getValue(); + req=new Ajax.Request("action_etichetta.php?op=update", + { + method:'POST', + parameters: { et_id: lid, et_nome: val}, + onComplete: function(transport) + { + if(isAjaxXMLRequest(req)) + { + values=parseXMLResponse(transport); + statusResp=values["status"]; + switch (statusResp) + { + case "201": + $("label_"+lid).removeClassName("edit_label_row"); + update_labels() + update_references(); + update_reference_labels(); + LAST_EDITED_LABEL=""; + break; + + case "202": undo_edit_label(lid) + break; + + case "501": + negative_serv_feedback('') + break; + case "502": + negative_serv_feedback('') + break; + } + + } + } + + }); +} + +function undo_edit_label(lid) +{ + req=new Ajax.Request("action_etichetta.php?op=restorelabel", + { + method:'POST', + asynchronous: false, + parameters: { et_id: lid}, + onComplete: function(transport) + { + $("label_"+lid).removeClassName("edit_label_row"); + $("label_"+lid).update(transport.responseText); + LAST_EDITED_LABEL=""; + } + + }); +} + +function update_label_creator() +{ + new Ajax.Updater('label_creator',"action_etichetta.php?op=update_label_creator"); + +} + + +function update_labels() +{ + req=new Ajax.Request("action_etichetta.php?op=update_labels", + { + method:'POST', + onComplete: function(transport) + { + $('eti_coll').update(transport.responseText); + + listaview=''; + listaview+=transport.responseText; + $('label').update(listaview); + } + + }); + + + update_label_creator() +} + +function update_reference_labels() +{ + if($('my_reference') && $('my_reference').visible()) + { + + if ($('item_labels') && $('item_labels').visible()) + { + + req=new Ajax.Request("action_etichetta.php?op=update_reference_labels", + { + method:'GET', + asynchronous: false, + onComplete: function(transport) + { + $('item_labels').replace(transport.responseText); + } + }); + } + } +} + + +function delete_rif(url) +{ + if(confirm('')) + { + update_references(url); + resetReferencePanel(); + } + +} + + +function print_references(url) +{ + if(selected_references()) + { + document.form_bibliografia.action="print_bibliografia.php"; + document.form_bibliografia.target="_blank" + document.form_bibliografia.submit(); + } +} + +function print_rif(id) +{ + alert(''); +} + +function check_all_references() +{ + var form = $('form_bibliografia') + + var rif_check = form.getInputs('checkbox', 'idrif[]') + + for (var i = 0; i < rif_check.length; i++) + { + rif_check[i].checked=$('checkall').checked; + } + +} + +function selectRifRow(id) +{ + elemento= $('item_'+id) + if(elemento) + selectListRow($('current_list_range'),elemento,'selected_item'); +} + +function clearSelectedRow() +{ + clearSelectedListRow($('current_list_range'),'selected_item'); +} + +function loadHistoryDD() +{ + url='action_bibliografia.php' + new Ajax.Updater('current_history_dd_list', url, + { + method:'GET', + parameters: {op: 'historyDD'} + }); +} + + +function activeNilde4_ute(idute) { + + if (from3to4SaveUte == 1){ + new Ajax.Request('action_utente.php', { method:'POST', + asynchronous: false, + parameters: {op:'from3to4',id:idute}, + onComplete:go ('mynilde.php') + } + ); + } else + + Dialog.alert('Warning, you will probably need to save the information in the panel
      "My Account"', + {className: 'alphacube' , + destroyOnClose:true , + width:400 , + maxHeight:200 , + recenterAuto: false , + showProgress: false , + showEffect: Effect.Appear, + showEffectOptions: {duration: 0.3} + }); +} + +function clean_refman_session() +{ + new Ajax.Request('action_refman.php', + { + method:'GET', + parameters: {op:'clean_refman_session'}, + onComplete: function(transport) {} + }); +} \ No newline at end of file